diff options
Diffstat (limited to 'build_scripts/utils.py')
-rw-r--r-- | build_scripts/utils.py | 60 |
1 files changed, 23 insertions, 37 deletions
diff --git a/build_scripts/utils.py b/build_scripts/utils.py index efb53ff25..74d9e6fc5 100644 --- a/build_scripts/utils.py +++ b/build_scripts/utils.py @@ -4,7 +4,6 @@ import errno import fnmatch import glob -import itertools import os import re import shutil @@ -18,17 +17,9 @@ from pathlib import Path from textwrap import dedent, indent from .log import log -from . import (PYSIDE_PYTHON_TOOLS, PYSIDE_LINUX_BIN_TOOLS, PYSIDE_LINUX_LIBEXEC_TOOLS, - PYSIDE_WINDOWS_BIN_TOOLS) +from . import (PYSIDE_PYTHON_TOOLS, PYSIDE_LINUX_BIN_TOOLS, PYSIDE_UNIX_LIBEXEC_TOOLS, + PYSIDE_WINDOWS_BIN_TOOLS, PYSIDE_UNIX_BIN_TOOLS, PYSIDE_UNIX_BUNDLED_TOOLS) -try: - # Using the distutils implementation within setuptools - from setuptools.errors import SetupError -except ModuleNotFoundError: - # This is motivated by our CI using an old version of setuptools - # so then the coin_build_instructions.py script is executed, and - # import from this file, it was failing. - from distutils.errors import DistutilsSetupError as SetupError try: WindowsError @@ -103,8 +94,8 @@ def copyfile(src, dst, force=True, _vars=None, force_copy_symlink=False, src = Path(src.format(**_vars)) if _vars else Path(src) if isinstance(dst, str): dst = Path(dst.format(**_vars)) if _vars else Path(dst) - assert(isinstance(src, Path)) - assert(isinstance(dst, Path)) + assert (isinstance(src, Path)) + assert (isinstance(dst, Path)) if not src.exists() and not force: log.info(f"**Skipping copy file\n {src} to\n {dst}\n Source does not exist") @@ -179,8 +170,8 @@ def copydir(src, dst, _filter=None, ignore=None, force=True, recursive=True, _va src = Path(src.format(**_vars)) if _vars else Path(src) if isinstance(dst, str): dst = Path(dst.format(**_vars)) if _vars else Path(dst) - assert(isinstance(src, Path)) - assert(isinstance(dst, Path)) + assert (isinstance(src, Path)) + assert (isinstance(dst, Path)) if _vars is not None: if _filter is not None: @@ -943,7 +934,7 @@ def get_python_dict(python_script_path): def get_qtci_virtualEnv(python_ver, host, hostArch, targetArch): _pExe = "python" - _env = f"env{python_ver}" + _env = f"{os.environ.get('PYSIDE_VIRTUALENV') or 'env'+python_ver}" env_python = f"{_env}/bin/python" env_pip = f"{_env}/bin/pip" @@ -958,7 +949,7 @@ def get_qtci_virtualEnv(python_ver, host, hostArch, targetArch): _path = Path(os.getenv(var, "")) _pExe = _path / "python.exe" if not _pExe.is_file(): - log.warn(f"Can't find python.exe from {_pExe}, using default python3") + log.warning(f"Can't find python.exe from {_pExe}, using default python3") _pExe = Path(os.getenv("PYTHON3_32_PATH")) / "python.exe" else: _pExe = Path(os.getenv("PYTHON2_32_PATH")) / "python.exe" @@ -969,7 +960,7 @@ def get_qtci_virtualEnv(python_ver, host, hostArch, targetArch): _path = Path(os.getenv(var, "")) _pExe = _path / "python.exe" if not _pExe.is_file(): - log.warn(f"Can't find python.exe from {_pExe}, using default python3") + log.warning(f"Can't find python.exe from {_pExe}, using default python3") _pExe = Path(os.getenv("PYTHON3_PATH")) / "python.exe" env_python = f"{_env}\\Scripts\\python.exe" env_pip = f"{_env}\\Scripts\\pip.exe" @@ -980,7 +971,7 @@ def get_qtci_virtualEnv(python_ver, host, hostArch, targetArch): except Exception as e: print(f"Exception {type(e).__name__}: {e}") _pExe = "python3" - return(_pExe, _env, env_pip, env_python) + return (_pExe, _env, env_pip, env_python) def run_instruction(instruction, error, initial_env=None): @@ -1143,29 +1134,24 @@ def available_pyside_tools(qt_tools_path: Path, package_for_wheels: bool = False if tool_exist(bin_path / f"{tool}.exe")]) else: lib_exec_path = qt_tools_path / "Qt" / "libexec" if package_for_wheels \ - else qt_tools_path / "libexec" - pyside_tools.extend([tool for tool in PYSIDE_LINUX_LIBEXEC_TOOLS + else qt_tools_path / "libexec" + pyside_tools.extend([tool for tool in PYSIDE_UNIX_LIBEXEC_TOOLS if tool_exist(lib_exec_path / tool)]) - pyside_tools.extend([tool for tool in PYSIDE_LINUX_BIN_TOOLS - if tool_exist(bin_path / tool)]) + if sys.platform == 'darwin': + def name_to_path(name): + return f"{name.capitalize()}.app/Contents/MacOS/{name.capitalize()}" + + pyside_tools.extend([tool for tool in PYSIDE_UNIX_BIN_TOOLS + if tool_exist(bin_path / tool)]) + pyside_tools.extend([tool for tool in PYSIDE_UNIX_BUNDLED_TOOLS + if tool_exist(bin_path / name_to_path(tool))]) + else: + pyside_tools.extend([tool for tool in PYSIDE_LINUX_BIN_TOOLS + if tool_exist(bin_path / tool)]) return pyside_tools -def find_qt_install_path() -> Path: - """ - Find Qt installation path - """ - - def where_is(x): - return Path(which(x)) - - qtpaths = where_is("qtpaths") if where_is("qtpaths") else where_is("qtpaths6") - if not qtpaths: - raise RuntimeError("qtpaths not found") - else: - return qtpaths.parents[1] - def copy_qt_metatypes(destination_qt_dir, _vars): """Copy the Qt metatypes files which changed location in 6.5""" # <qt>/[lib]?/metatypes/* -> <setup>/{st_package_name}/Qt/[lib]?/metatypes |