From ef6536bbb228230528d62d6e246f862373aad77e Mon Sep 17 00:00:00 2001 From: Libba Lawrence Date: Fri, 22 May 2026 13:42:59 -0700 Subject: [PATCH] Skip cibuildwheel for dev-requirement wheels with C extensions `cibuildwheel` downloads its own CPython from nuget.org which is not reachable from internal 1ES pool agents (egress returns RFC-5737 sinkhole IPs). For dev-requirement builds the wheel only needs to install into the current venv, so opt out of cibuildwheel and let `setup.py bdist_wheel` run with the invoking Python. Release builds (`build_packages`) keep the default behavior so they continue to produce the abi3 wheel via cibuildwheel on agents that can reach nuget.org. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- eng/tools/azure-sdk-tools/ci_tools/build.py | 14 ++++++++++++-- .../ci_tools/scenario/generation.py | 7 ++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/eng/tools/azure-sdk-tools/ci_tools/build.py b/eng/tools/azure-sdk-tools/ci_tools/build.py index 26ac6fcfd15a..7932c3d9f040 100644 --- a/eng/tools/azure-sdk-tools/ci_tools/build.py +++ b/eng/tools/azure-sdk-tools/ci_tools/build.py @@ -218,11 +218,21 @@ def build_packages( def create_package( - setup_directory_or_file: str, dest_folder: str, enable_wheel: bool = True, enable_sdist: bool = True + setup_directory_or_file: str, + dest_folder: str, + enable_wheel: bool = True, + enable_sdist: bool = True, + use_cibuildwheel: bool = True, ): """ Uses the invoking python executable to build a wheel and sdist file given a setup.py or setup.py directory. Outputs into a distribution directory and defaults to the value of get_artifact_directory(). + + When ``use_cibuildwheel`` is False, packages with C extension modules are built with the + invoking Python via ``setup.py bdist_wheel`` instead of ``cibuildwheel``. This is the + appropriate choice when the wheel is only consumed by the current venv (e.g. dev-requirement + installs in CI), since ``cibuildwheel`` otherwise downloads a fresh CPython from nuget.org + which is not reachable from all CI agents. """ dist = get_artifact_directory(dest_folder) @@ -263,7 +273,7 @@ def create_package( ) else: if enable_wheel: - if setup_parsed.ext_modules: + if setup_parsed.ext_modules and use_cibuildwheel: run_logged( [sys.executable, "-m", "cibuildwheel", "--output-dir", dist], cwd=setup_parsed.folder, diff --git a/eng/tools/azure-sdk-tools/ci_tools/scenario/generation.py b/eng/tools/azure-sdk-tools/ci_tools/scenario/generation.py index 58d4899a9757..89ec0cadc408 100644 --- a/eng/tools/azure-sdk-tools/ci_tools/scenario/generation.py +++ b/eng/tools/azure-sdk-tools/ci_tools/scenario/generation.py @@ -350,7 +350,12 @@ def build_whl_for_req(req: str, package_path: str, wheel_dir: Optional[str]) -> os.mkdir(temp_dir) logging.info("Building wheel for package {}".format(parsed.name)) - create_package(req_pkg_path, temp_dir, enable_sdist=False) + # ``cibuildwheel`` is intended for producing release artifacts that span multiple + # Python versions; it downloads its own CPython from nuget.org which is not + # reachable from all CI agents. For dev-requirements builds the wheel only needs + # to install into the current venv, so opt out of ``cibuildwheel`` here and let + # ``setup.py bdist_wheel`` run with the invoking Python. + create_package(req_pkg_path, temp_dir, enable_sdist=False, use_cibuildwheel=False) whl_path = os.path.join(temp_dir, find_whl(temp_dir, parsed.name, parsed.version))