Skip to content
Merged
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
3 changes: 3 additions & 0 deletions cibuildwheel/platforms/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ def build(options: Options, tmp_path: Path) -> None:
and "-n" not in extra_flags
):
extra_flags.append("--installer=uv")
if pip_version is not None:
# build's isolated virtualenv seeds its own bundled pip otherwise, see #2984
build_env.setdefault("VIRTUALENV_PIP", pip_version)
call(
"python",
"-m",
Expand Down
6 changes: 5 additions & 1 deletion cibuildwheel/platforms/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@ def build(options: Options, tmp_path: Path) -> None:
and "-n" not in extra_flags
):
extra_flags.append("--installer=uv")
build_env = env.copy()
if pip_version is not None:
# build's isolated virtualenv seeds its own bundled pip otherwise, see #2984
build_env.setdefault("VIRTUALENV_PIP", pip_version)

call(
"python",
Expand All @@ -527,7 +531,7 @@ def build(options: Options, tmp_path: Path) -> None:
"--wheel",
f"--outdir={built_wheel_dir}",
*extra_flags,
env=env,
env=build_env,
)
case "uv":
assert uv_path is not None
Expand Down
42 changes: 42 additions & 0 deletions test/test_dependency_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,45 @@ def test_dependency_constraints(
expected_wheels = utils.expected_wheels("spam", "0.1.0", single_python=True)

assert set(actual_wheels) == set(expected_wheels)


project_with_isolated_pip_check = test_projects.new_c_project(
setup_py_add=textwrap.dedent(
"""
from importlib.metadata import PackageNotFoundError, version

with open("outer_pip_version.txt") as f:
outer_pip_version = f.read().strip()
try:
isolated_pip_version = version("pip")
except PackageNotFoundError:
# venv backend: build installs with the outer pip
isolated_pip_version = outer_pip_version
assert isolated_pip_version == outer_pip_version, (isolated_pip_version, outer_pip_version)
"""
)
)


def test_build_isolated_env_pip_version(tmp_path: Path) -> None:
# build's isolated virtualenv seeds the same pip as the build venv, see #2984
if utils.get_platform() not in {"macos", "windows"}:
pytest.skip("only macOS and Windows can use the build frontend's virtualenv backend")

project_dir = tmp_path / "project"
project_with_isolated_pip_check.generate(project_dir)

add_env = {
"CIBW_BUILD_FRONTEND": "build",
"CIBW_BEFORE_BUILD": (
'python -c "import importlib.metadata as m, pathlib;'
" pathlib.Path('outer_pip_version.txt').write_text(m.version('pip'))\""
),
# differs from the pip bundled with virtualenv
"CIBW_DEPENDENCY_VERSIONS": "packages: pip==25.3",
}

actual_wheels = utils.cibuildwheel_run(project_dir, add_env=add_env, single_python=True)

expected_wheels = utils.expected_wheels("spam", "0.1.0", single_python=True)
assert set(actual_wheels) == set(expected_wheels)
Loading