diff --git a/cibuildwheel/platforms/macos.py b/cibuildwheel/platforms/macos.py index ad084fd6..37c3d799 100644 --- a/cibuildwheel/platforms/macos.py +++ b/cibuildwheel/platforms/macos.py @@ -253,6 +253,10 @@ def setup_python( # https://github.com/pypa/virtualenv/issues/620 # Also see https://github.com/python/cpython/pull/9516 env.pop("__PYVENV_LAUNCHER__", None) + # uv uses this over the current environment's python, so remove it to avoid confusion + env.pop("PYTHON_VERSION", None) + env.pop("PYTHON_ARCH", None) + env.pop("UV_PYTHON", None) # we version pip ourselves, so we don't care about pip version checking env["PIP_DISABLE_PIP_VERSION_CHECK"] = "1" @@ -370,6 +374,8 @@ def setup_python( uv_path, "pip", "install", + "--python", + which_python, "--upgrade", "delocate", "build[virtualenv, uv]", @@ -382,6 +388,8 @@ def setup_python( uv_path, "pip", "install", + "--python", + which_python, "--upgrade", "delocate", *constraint_flags(dependency_constraint), diff --git a/cibuildwheel/platforms/windows.py b/cibuildwheel/platforms/windows.py index 18d400a9..3bb9e86f 100644 --- a/cibuildwheel/platforms/windows.py +++ b/cibuildwheel/platforms/windows.py @@ -293,7 +293,9 @@ def setup_python( # set up environment variables for run_with_env env["PYTHON_VERSION"] = python_configuration.version env["PYTHON_ARCH"] = python_configuration.arch - env["PIP_DISABLE_PIP_VERSION_CHECK"] = "1" + env.pop("UV_PYTHON", None) + if not use_uv: + env["PIP_DISABLE_PIP_VERSION_CHECK"] = "1" # update env with results from CIBW_ENVIRONMENT env = environment.as_dictionary(prev_environment=env) @@ -334,6 +336,8 @@ def setup_python( uv_path, "pip", "install", + "--python", + where_python, "--upgrade", "build[virtualenv]", *constraint_flags(dependency_constraint),