From 0fe600eea319ee508bc834f95355a6e9404e00b8 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Sat, 8 Oct 2022 15:53:46 -0400 Subject: [PATCH 1/3] ci: avoid editable installs with old pip --- .circleci/prepare.sh | 2 +- .cirrus.yml | 2 +- appveyor.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/prepare.sh b/.circleci/prepare.sh index 991f0202..b7bcf35f 100644 --- a/.circleci/prepare.sh +++ b/.circleci/prepare.sh @@ -5,6 +5,6 @@ set -o xtrace $PYTHON --version $PYTHON -m pip --version $PYTHON -m virtualenv -p "$PYTHON" venv -venv/bin/python -m pip install -e ".[dev]" +venv/bin/python -m pip install ".[dev]" venv/bin/python -m pip freeze venv/bin/python --version diff --git a/.cirrus.yml b/.cirrus.yml index 4ba969ea..0537775d 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,6 +1,6 @@ run_tests: &RUN_TESTS install_cibuildwheel_script: - - python -m pip install -e ".[dev]" pytest-custom-exit-code + - python -m pip install ".[dev]" pytest-custom-exit-code run_cibuildwheel_tests_script: - python ./bin/run_tests.py diff --git a/appveyor.yml b/appveyor.yml index fbea6b73..e2a00991 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,7 +20,7 @@ init: } python -m pip install -U pip -install: python -m pip install -e ".[dev]" pytest-custom-exit-code +install: python -m pip install ".[dev]" pytest-custom-exit-code # the '-u' flag is required so the output is in the correct order. # See https://github.com/pypa/cibuildwheel/pull/24 for more info. From 1ee0692f680753d2c2706c5a52e557fe958e3265 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Sat, 8 Oct 2022 15:58:04 -0400 Subject: [PATCH 2/3] Revert "ci: avoid editable installs with old pip" This reverts commit 0fe600eea319ee508bc834f95355a6e9404e00b8. --- .circleci/prepare.sh | 2 +- .cirrus.yml | 2 +- appveyor.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/prepare.sh b/.circleci/prepare.sh index b7bcf35f..991f0202 100644 --- a/.circleci/prepare.sh +++ b/.circleci/prepare.sh @@ -5,6 +5,6 @@ set -o xtrace $PYTHON --version $PYTHON -m pip --version $PYTHON -m virtualenv -p "$PYTHON" venv -venv/bin/python -m pip install ".[dev]" +venv/bin/python -m pip install -e ".[dev]" venv/bin/python -m pip freeze venv/bin/python --version diff --git a/.cirrus.yml b/.cirrus.yml index 0537775d..4ba969ea 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,6 +1,6 @@ run_tests: &RUN_TESTS install_cibuildwheel_script: - - python -m pip install ".[dev]" pytest-custom-exit-code + - python -m pip install -e ".[dev]" pytest-custom-exit-code run_cibuildwheel_tests_script: - python ./bin/run_tests.py diff --git a/appveyor.yml b/appveyor.yml index e2a00991..fbea6b73 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,7 +20,7 @@ init: } python -m pip install -U pip -install: python -m pip install ".[dev]" pytest-custom-exit-code +install: python -m pip install -e ".[dev]" pytest-custom-exit-code # the '-u' flag is required so the output is in the correct order. # See https://github.com/pypa/cibuildwheel/pull/24 for more info. From 758dfec5939352baf7873ed29d69dc7916767119 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Sun, 9 Oct 2022 16:44:14 +0200 Subject: [PATCH 3/3] chore: better error message when python is missing in an OCI image (#1298) --- cibuildwheel/linux.py | 25 +++++++++++++++++++++++ test/test_linux_python.py | 43 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 test/test_linux_python.py diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index c9134e7e..e0f4add2 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -110,6 +110,29 @@ def get_build_steps( yield from steps.values() +def check_all_python_exist( + *, platform_configs: list[PythonConfiguration], container: OCIContainer +) -> None: + exist = True + messages = [] + for config in platform_configs: + python_path = config.path / "bin" / "python" + try: + container.call(["test", "-x", python_path]) + except subprocess.CalledProcessError: + messages.append( + f" '{python_path}' executable doesn't exist in image '{container.image}' to build '{config.identifier}'." + ) + exist = False + if not exist: + message = "\n".join(messages) + print( + f"cibuildwheel:\n{message}", + file=sys.stderr, + ) + sys.exit(1) + + def build_in_container( *, options: Options, @@ -120,6 +143,8 @@ def build_in_container( ) -> None: container_output_dir = PurePosixPath("/output") + check_all_python_exist(platform_configs=platform_configs, container=container) + log.step("Copying project into container...") container.copy_into(Path.cwd(), container_project_path) diff --git a/test/test_linux_python.py b/test/test_linux_python.py new file mode 100644 index 00000000..7b642916 --- /dev/null +++ b/test/test_linux_python.py @@ -0,0 +1,43 @@ +from __future__ import annotations + +import platform +import subprocess + +import pytest + +from . import test_projects, utils + + +def test_python_exist(tmp_path, capfd): + if utils.platform != "linux": + pytest.skip("the test is only relevant to the linux build") + machine = platform.machine() + if machine not in ["x86_64", "i686"]: + pytest.skip( + "this test is currently only possible on x86_64/i686 due to availability of alternative images" + ) + + project_dir = tmp_path / "project" + basic_project = test_projects.new_c_project() + basic_project.generate(project_dir) + + with pytest.raises(subprocess.CalledProcessError): + utils.cibuildwheel_run( + project_dir, + add_env={ + "CIBW_MANYLINUX_X86_64_IMAGE": "manylinux2010", + "CIBW_MANYLINUX_I686_IMAGE": "manylinux2010", + "CIBW_BUILD": "cp3{10,11}-manylinux*", + }, + ) + + captured = capfd.readouterr() + print("out", captured.out) + print("err", captured.err) + assert f" to build 'cp310-manylinux_{machine}'." not in captured.err + message = ( + "'/opt/python/cp311-cp311/bin/python' executable doesn't exist" + f" in image 'quay.io/pypa/manylinux2010_{machine}:2022-08-05-4535177'" + f" to build 'cp311-manylinux_{machine}'." + ) + assert message in captured.err