diff options
author | Shyamnath Premnadh <shyamnath.premnadh@qt.io> | 2023-03-20 10:51:56 +0100 |
---|---|---|
committer | Shyamnath Premnadh <shyamnath.premnadh@qt.io> | 2023-03-27 09:01:18 +0100 |
commit | 4d4f744c570d2feb79163051d2fd4c73336f1758 (patch) | |
tree | 372f4e18fe6978d1441164352836e88f8b1647ab /sources/pyside-tools/deploy_lib | |
parent | 5529853210de3e51b2ad3c636ebee4a4d77aa54e (diff) |
Deployment Tool: Remove create_venv + fix --dry-run/--init
- As the deployment tool's code base grows larger, I realized that
the ability to create a venv using pyside6-deploy was a bit of
over engineering. There are instances where I have to use the
current Python interpreter to fetch some information from the
newly created venv Python, which results in weird code.
Note: The tool would still work even if the user is using a
globally installed Python interpreter with PySide6 installed.
- Now, the user is warned if he is not in a virtual environment and
prompted the requirement to install further Python packages. If
the user input's "no", then the tool exits.
- dry_run used to create an empty 'pysidedeploy.spec' which can
wreck the normal deployment process. This is fixed by
pyside6-deploy using the 'default.spec' instead of creating
a new 'pysidedeploy.spec'.
Fixes: PYSIDE-2258
Task-number: PYSIDE-1612
Pick-to: 6.4 6.5
Change-Id: I376d2a6aea9f93582eab7a904a81f48426bfee18
Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside-tools/deploy_lib')
-rw-r--r-- | sources/pyside-tools/deploy_lib/config.py | 7 | ||||
-rw-r--r-- | sources/pyside-tools/deploy_lib/python_helper.py | 20 |
2 files changed, 6 insertions, 21 deletions
diff --git a/sources/pyside-tools/deploy_lib/config.py b/sources/pyside-tools/deploy_lib/config.py index ba165d20b..03dff70bf 100644 --- a/sources/pyside-tools/deploy_lib/config.py +++ b/sources/pyside-tools/deploy_lib/config.py @@ -24,8 +24,11 @@ class Config: self.config_file = config_file self.parser = ConfigParser(comment_prefixes="/", allow_no_value=True) if not self.config_file.exists(): - logging.info(f"[DEPLOY] Creating config file {self.config_file}") - shutil.copy(Path(__file__).parent / "default.spec", self.config_file) + if not dry_run: + logging.info(f"[DEPLOY] Creating config file {self.config_file}") + shutil.copy(Path(__file__).parent / "default.spec", self.config_file) + else: + self.config_file = Path(__file__).parent / "default.spec" else: print(f"Using existing config file {config_file}") self.parser.read(self.config_file) diff --git a/sources/pyside-tools/deploy_lib/python_helper.py b/sources/pyside-tools/deploy_lib/python_helper.py index cc9a448b0..2fc0236bc 100644 --- a/sources/pyside-tools/deploy_lib/python_helper.py +++ b/sources/pyside-tools/deploy_lib/python_helper.py @@ -19,11 +19,9 @@ class PythonExecutable: Wrapper class around Python executable """ - def __init__(self, python_path=None, create_venv=False, dry_run=False): + def __init__(self, python_path=None, dry_run=False): self.exe = python_path if python_path else Path(sys.executable) self.dry_run = dry_run - if create_venv: - self.__create_venv() self.nuitka = Nuitka(nuitka=[os.fspath(self.exe), "-m", "nuitka"]) @property @@ -39,21 +37,6 @@ class PythonExecutable: venv = os.environ.get("VIRTUAL_ENV") return True if venv else False - def __create_venv(self): - self.install("virtualenv") - if not self.is_venv(): - run_command( - command=[self.exe, "-m", "venv", Path.cwd() / "deployment" / "venv"], - dry_run=self.dry_run, - ) - venv_path = Path(os.environ["VIRTUAL_ENV"]) - if sys.platform == "win32": - self.exe = venv_path / "Scripts" / "python.exe" - elif sys.platform in ["linux", "darwin"]: - self.exe = venv_path / "bin" / "python" - else: - logging.info("[DEPLOY] You are already in virtual environment!") - def install(self, packages: list = None): for package in packages: package_info = package.split('==') @@ -104,4 +87,3 @@ class PythonExecutable: ) return command_str - |