Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion cibuildwheel/platforms/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,14 @@ def build(options: Options, tmp_path: Path) -> None:
else:
testing_archs = ["x86_64"]

# Start the test environment again from the host environment,
# rather than the build environment, so that build-specific
# variables (such as _PYTHON_HOST_PLATFORM, ARCHFLAGS and
# SDKROOT) don't leak into the test environment. See #1863.
# The user's `environment` option still applies, since it
# covers the build and test phases.
test_base_env = build_options.environment.as_dictionary(prev_environment=os.environ)

for testing_arch in testing_archs:
if config_is_universal2:
arch_specific_identifier = f"{config.identifier}:{testing_arch}"
Expand Down Expand Up @@ -718,7 +726,7 @@ def build(options: Options, tmp_path: Path) -> None:
venv_dir,
None,
use_uv=use_uv,
env=env,
env=test_base_env,
pip_version=pip_version,
)
if use_uv:
Expand All @@ -727,6 +735,7 @@ def build(options: Options, tmp_path: Path) -> None:
pip_install = functools.partial(call_with_arch, *pip, "install")

virtualenv_env["MACOSX_DEPLOYMENT_TARGET"] = get_test_macosx_deployment_target()
virtualenv_env["CIBUILDWHEEL_BUILD_IDENTIFIER"] = config.identifier

virtualenv_env = build_options.test_environment.as_dictionary(
prev_environment=virtualenv_env
Expand Down
10 changes: 9 additions & 1 deletion cibuildwheel/platforms/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,13 @@ def build(options: Options, tmp_path: Path) -> None:
# skip this test
elif test_selected and build_options.test_command:
log.step("Testing wheel...")
# Start the test environment again from the host environment,
# rather than the build environment, so that build-specific
# variables (such as PYTHON_VERSION and PYTHON_ARCH) don't
# leak into the test environment. See #1863. The user's
# `environment` option still applies, since it covers the
# build and test phases.
test_base_env = build_options.environment.as_dictionary(prev_environment=os.environ)
# set up a virtual environment to install and test from, to make sure
# there are no dependencies that were pulled in at build time.
venv_dir = identifier_tmp_dir / "venv-test"
Expand All @@ -604,10 +611,11 @@ def build(options: Options, tmp_path: Path) -> None:
venv_dir,
None,
use_uv=use_uv,
env=env,
env=test_base_env,
pip_version=pip_version,
)

virtualenv_env["CIBUILDWHEEL_BUILD_IDENTIFIER"] = config.identifier
virtualenv_env = build_options.test_environment.as_dictionary(
prev_environment=virtualenv_env
)
Expand Down
Loading