From 2f49f9a050c42805d0f0c5cfd7083637c11a5b4e Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 3 Jun 2026 15:23:06 -0400 Subject: [PATCH] fix: minor 4.0 issues in Android validation, docs, and docstring (#2891) * fix: minor 4.0 issues in android validation, docs, and docstring - android: raise a clear FatalError when ANDROID_API_LEVEL is not an integer, instead of an uncaught ValueError deep in localized_vars - docs: note that delvewheel is the default Windows repair-wheel-command since 4.0 and how to skip it for platform-tagged wheels with no extension module; update the now-outdated FAQ wording - venv: fix _parse_pip_constraint_for_virtualenv docstring to say marker-bearing constraints are evaluated against the host's default environment (not skipped) when marker_env is None Assisted-by: ClaudeCode:claude-opus-4.8 * fix: use int() with original error for ANDROID_API_LEVEL validation Handle ANDROID_API_LEVEL validation via try/except around int() so the original exception message is surfaced, and so non-ASCII Unicode digits (which isdigit() accepts but int() may reject) are handled correctly. Assisted-by: ClaudeCode:claude-opus-4.8 * refactor: address reivew by moving error catch Assisted-by: ClaudeCode:claude-opus-4.8 Signed-off-by: Henry Schreiner --------- Signed-off-by: Henry Schreiner --- cibuildwheel/platforms/android.py | 6 +++++- cibuildwheel/venv.py | 2 +- docs/faq.md | 2 +- docs/options.md | 3 +++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cibuildwheel/platforms/android.py b/cibuildwheel/platforms/android.py index 3a1cc1b2..032d7730 100644 --- a/cibuildwheel/platforms/android.py +++ b/cibuildwheel/platforms/android.py @@ -349,7 +349,11 @@ def localized_vars( final = final.replace(orig_prefix, str(prefix)) if key == "ANDROID_API_LEVEL": - final = int(build_env[key]) + try: + final = int(build_env[key]) + except ValueError as e: + msg = f"ANDROID_API_LEVEL: {e}. This variable must be an integer." + raise errors.FatalError(msg) from e # Build systems vary in whether FLAGS variables are read from sysconfig, and if so, # whether they're replaced by environment variables or combined with them. Even diff --git a/cibuildwheel/venv.py b/cibuildwheel/venv.py index 10f49491..68404cac 100644 --- a/cibuildwheel/venv.py +++ b/cibuildwheel/venv.py @@ -84,7 +84,7 @@ def _parse_pip_constraint_for_virtualenv( If it can't get an exact version, the real constraint will be handled by the {macos|windows}.setup_python function. If marker_env is provided, marker-bearing constraints are evaluated against it; - otherwise, marker-bearing constraints are skipped. + otherwise, they are evaluated against the host's default environment. """ env: dict[str, str] = ( marker_env if marker_env is not None else cast("dict[str, str]", default_environment()) diff --git a/docs/faq.md b/docs/faq.md index c8a12b01..d71ef2b5 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -235,7 +235,7 @@ Sometimes a build will fail due to a missing dependency. **If you need a build tool** (e.g. cmake, automake, ninja), you can install it through a package manager like apt/yum, brew or choco, using the [`before-all`](options.md#before-all) option. -**If your build is linking into a native library dependency**, you can build/install that in [`before-all`](options.md#before-all). However, on Linux, Mac (and Windows if you're using [delvewheel]), the library that you install will be bundled into the wheel in the [repair step]. So take care to ensure that +**If your build is linking into a native library dependency**, you can build/install that in [`before-all`](options.md#before-all). However, on Linux, Mac, and Windows (which uses [delvewheel] by default since cibuildwheel 4.0), the library that you install will be bundled into the wheel in the [repair step]. So take care to ensure that - the bundled library doesn't accidentally increase the minimum system requirements (such as the minimum macOS version) - the bundled library matches the architecture of the wheel you're building when cross-compiling diff --git a/docs/options.md b/docs/options.md index 7a8b84fb..c18e8afe 100644 --- a/docs/options.md +++ b/docs/options.md @@ -971,6 +971,9 @@ Default: A shell command to repair a built wheel by copying external library dependencies into the wheel tree and relinking them. The command is run on each built wheel (except for pure Python ones) before testing it. +!!! note + Since cibuildwheel 4.0, `delvewheel` is the default `repair-wheel-command` on Windows, so extension-module DLLs are bundled automatically. If a wheel has a platform tag but contains no extension module (for example, a package that sets a platform tag but ships a pre-built DLL itself), `delvewheel` may error. In that case, set `repair-wheel-command = ""` to skip the repair step. + The following placeholders must be used inside the command and will be replaced by cibuildwheel: - `{wheel}` for the absolute path to the built wheel