aboutsummaryrefslogtreecommitdiffstats
path: root/create_wheels.py
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-11-30 12:53:49 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-12-01 15:50:46 +0100
commitc2b73dfc245b48cd6de7a6461d56b73f84654bf1 (patch)
treed42472ff732e5c58ff7ce06bb122083d300cb9d0 /create_wheels.py
parentb7a809650fc4f911b2eda2ab3b8acfcc632ba61a (diff)
create_wheels: Make build directory detection a bit smarter
Do not assume the testenv is named qfp. Also check for the debug postfixes, fall back to globbing. Change-Id: Ia09090be8f6e3da68b5e99b4f38a3d2bc337c345 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'create_wheels.py')
-rw-r--r--create_wheels.py50
1 files changed, 26 insertions, 24 deletions
diff --git a/create_wheels.py b/create_wheels.py
index 53e04607a..ebf4fe8f9 100644
--- a/create_wheels.py
+++ b/create_wheels.py
@@ -18,6 +18,9 @@ from build_scripts.wheel_files import (ModuleData, # type: ignore
from build_scripts.utils import available_pyside_tools
+PACKAGE_FOR_WHEELS = "package_for_wheels"
+
+
@dataclass
class SetupData:
name: str
@@ -231,29 +234,27 @@ def wheel_pyside6() -> Tuple[SetupData, Optional[List[ModuleData]]]:
return setup, None
-def get_build_directory(options: Namespace):
- _venv = ""
- _directories = list(Path("build").glob("qfp*"))
- # Search for a "--env" option first"
- if options.env is not None:
- _venv = f"{options.env}a"
- # Search for a 'qfp' directory second
- elif _directories and len(_directories) > 0:
- # Take the first 'qfp' directory
- _venv = _directories[0].name
- # Fall back to the virtual environment name
- else:
- # Check if we are using a virtual environment
- try:
- _venv = os.environ["VIRTUAL_ENV"]
- if not _venv:
- raise Exception("No virtual environment found")
- _venv = f"{_venv}a"
- except Exception as e:
- print(f"{type(e).__name__} : {e}")
- sys.exit(-1)
+def venv_name():
+ v = os.environ.get("VIRTUAL_ENV")
+ return Path(v).name if v else None
+
- return Path(_venv)
+def get_build_directory(options: Namespace):
+ build_dir = Path("build")
+ # Search for a "--env" option first", try postfix "a" for limited API or "d", debug
+ venv = options.env if options.env else venv_name()
+ if venv:
+ for postfix in ("a", "d", ""):
+ result = build_dir / f"{venv}{postfix}"
+ if result.is_dir():
+ return result
+ if options.env:
+ raise Exception(f'Invalid environment "{options.env}" passed')
+ # Fallback to existing dirs (skip "config.tests")
+ for d in build_dir.glob("*"):
+ if (d / PACKAGE_FOR_WHEELS).is_dir():
+ return d
+ raise Exception("Unable to determine build directory, no matching virtual environment found")
if __name__ == "__main__":
@@ -263,7 +264,7 @@ if __name__ == "__main__":
parser.add_argument("--env", type=str, default=None)
options = parser.parse_args()
- venv = get_build_directory(options)
+ build_directory = get_build_directory(options)
verbose = False
# Setup paths
@@ -271,7 +272,8 @@ if __name__ == "__main__":
artifacts_path = Path("wheel_artifacts/")
# the extra 'a' is for compatibility with the build_scripts
# notation that adds an 'a' when using limited-api
- package_path = Path("build") / venv.name / "package_for_wheels"
+ package_path = build_directory / PACKAGE_FOR_WHEELS
+ print(f'Using build dir "{build_directory.name}"')
# Check for 'package_for_wheels' directory
if not package_path.is_dir():