From 49f85acb6c983d14b46f8d8ff17bceadec510705 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Sun, 14 Mar 2021 11:33:29 +0100 Subject: [PATCH] Bugfixes --- src/cpl/utils/pip.py | 2 +- src/cpl_cli/command/update_service.py | 55 ++++++++++++++------------- src/tests/custom/general/cpl.json | 4 +- 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/cpl/utils/pip.py b/src/cpl/utils/pip.py index bc8c0db3..5b09869f 100644 --- a/src/cpl/utils/pip.py +++ b/src/cpl/utils/pip.py @@ -26,7 +26,7 @@ class Pip: @staticmethod def install(package: str, *args, source: str = None, stdout=None, stderr=None): - pip_args = [sys.executable, "-m", "pip", "install", "--yes"] + pip_args = [sys.executable, "-m", "pip", "install"] for arg in args: pip_args.append(arg) diff --git a/src/cpl_cli/command/update_service.py b/src/cpl_cli/command/update_service.py index cc6d47c6..3509a620 100644 --- a/src/cpl_cli/command/update_service.py +++ b/src/cpl_cli/command/update_service.py @@ -23,6 +23,34 @@ class UpdateService(CommandABC): def _get_outdated() -> bytes: return subprocess.check_output([sys.executable, "-m", "pip", "list", "--outdated"]) + def _update_project_dependencies(self): + for package in self._project_settings.dependencies: + name = package + if '==' in package: + name = package.split('==')[0] + + if 'sh_cpl' in name: + Pip.install( + name, + '--upgrade', + '--upgrade-strategy', + 'eager', + source='https://pip.sh-edraft.de', + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL + ) + else: + Pip.install( + name, + '--upgrade', + '--upgrade-strategy', + 'eager', + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL + ) + + self._project_json_update_dependency(package, Pip.get_package(name)) + def _check_project_dependencies(self): Console.spinner( 'Collecting installed dependencies', self._update_project_dependencies, @@ -63,36 +91,9 @@ class UpdateService(CommandABC): project.write(json.dumps(json.loads(content), indent=2)) project.close() - def _update_project_dependencies(self): - for package in self._project_settings.dependencies: - name = package - if '==' in package: - name = package.split('==')[0] - Pip.install( - name, - '--upgrade', - '--upgrade-strategy', - 'eager', - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL - ) - - self._project_json_update_dependency(package, Pip.get_package(name)) - def run(self, args: list[str]): # target update discord 1.5.1 to discord 1.6.0 self._check_project_dependencies() - - Console.spinner( - 'Checking update for sh_cpl', - Pip.install, 'sh_cpl', - source='https://pip.sh-edraft.de', - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - text_foreground_color=ForegroundColorEnum.green, - spinner_foreground_color=ForegroundColorEnum.cyan - ) - self._check_outdated() Console.write('\n') diff --git a/src/tests/custom/general/cpl.json b/src/tests/custom/general/cpl.json index ad5855e2..5ae65fb3 100644 --- a/src/tests/custom/general/cpl.json +++ b/src/tests/custom/general/cpl.json @@ -15,7 +15,9 @@ "CopyrightName": "sh-edraft.de", "LicenseName": "MIT", "LicenseDescription": "MIT, see LICENSE for more details.", - "Dependencies": [], + "Dependencies": [ + "sh_cpl==2021.4.1" + ], "PythonVersion": ">=3.8" }, "BuildSettings": {