Skip to content
Closed
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
15 changes: 8 additions & 7 deletions cibuildwheel/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,23 @@ def install_pypy(tmp: Path, url: str) -> Path:
return installation_path / "bin" / "pypy3"


def can_use_uv(python_configuration: PythonConfiguration) -> bool:
conditions = (Version(python_configuration.version) >= Version("3.8"),)
return all(conditions)


def setup_python(
tmp: Path,
python_configuration: PythonConfiguration,
dependency_constraint_flags: Sequence[PathOrStr],
environment: ParsedEnvironment,
build_frontend: BuildFrontendName,
) -> tuple[Path, dict[str, str]]:
if build_frontend == "build[uv]" and Version(python_configuration.version) < Version("3.8"):
if build_frontend == "build[uv]" and not can_use_uv(python_configuration):
build_frontend = "build"

uv_path = find_uv()
use_uv = build_frontend == "build[uv]" and Version(python_configuration.version) >= Version(
"3.8"
)
use_uv = build_frontend == "build[uv]"

tmp.mkdir()
implementation_id = python_configuration.identifier.split("-")[0]
Expand Down Expand Up @@ -415,9 +418,7 @@ def build(options: Options, tmp_path: Path) -> None:
for config in python_configurations:
build_options = options.build_options(config.identifier)
build_frontend = build_options.build_frontend or BuildFrontendConfig("pip")
use_uv = build_frontend.name == "build[uv]" and Version(config.version) >= Version(
"3.8"
)
use_uv = build_frontend.name == "build[uv]" and can_use_uv(config)
uv_path = find_uv()
if use_uv and uv_path is None:
msg = "uv not found"
Expand Down
5 changes: 3 additions & 2 deletions cibuildwheel/oci_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ def __enter__(self) -> Self:
"create",
"--env=CIBUILDWHEEL",
"--env=SOURCE_DATE_EPOCH",
"--user=root",
f"--name={self.name}",
"--interactive",
*(["--volume=/:/host"] if not self.engine.disable_host_mount else []),
Expand Down Expand Up @@ -311,10 +312,10 @@ def __exit__(
def copy_into(self, from_path: Path, to_path: PurePath) -> None:
if from_path.is_dir():
self.call(["mkdir", "-p", to_path])
call(self.engine.name, "cp", f"{from_path}/.", f"{self.name}:{to_path}")
call(self.engine.name, "cp", "-a", f"{from_path}/.", f"{self.name}:{to_path}")
else:
self.call(["mkdir", "-p", to_path.parent])
call(self.engine.name, "cp", from_path, f"{self.name}:{to_path}")
call(self.engine.name, "cp", "-a", from_path, f"{self.name}:{to_path}")

def copy_out(self, from_path: PurePath, to_path: Path) -> None:
# note: we assume from_path is a dir
Expand Down
23 changes: 13 additions & 10 deletions cibuildwheel/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,14 @@ def setup_rust_cross_compile(
)


def can_use_uv(python_configuration: PythonConfiguration) -> bool:
conditions = (
Version(python_configuration.version) >= Version("3.8"),
not python_configuration.identifier.startswith("pp38-"),
)
return all(conditions)


def setup_python(
tmp: Path,
python_configuration: PythonConfiguration,
Expand Down Expand Up @@ -254,11 +262,10 @@ def setup_python(
raise ValueError(msg)
assert base_python.exists()

use_uv = (
build_frontend == "build[uv]"
and Version(python_configuration.version) >= Version("3.8")
and not python_configuration.identifier.startswith("pp38-")
)
if build_frontend == "build[uv]" and not can_use_uv(python_configuration):
build_frontend = "build"

use_uv = build_frontend == "build[uv]"
uv_path = find_uv()

log.step("Setting up build environment...")
Expand Down Expand Up @@ -368,11 +375,7 @@ def build(options: Options, tmp_path: Path) -> None:
for config in python_configurations:
build_options = options.build_options(config.identifier)
build_frontend = build_options.build_frontend or BuildFrontendConfig("pip")
use_uv = (
build_frontend.name == "build[uv]"
and Version(config.version) >= Version("3.8")
and not config.identifier.startswith("pp38-")
)
use_uv = build_frontend.name == "build[uv]" and can_use_uv(config)
log.build_start(config.identifier)

identifier_tmp_dir = tmp_path / config.identifier
Expand Down
14 changes: 14 additions & 0 deletions unit_test/oci_container_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ def test_file_operation(tmp_path: Path, container_engine):

container.copy_into(original_test_file, dst_file)

owner = container.call(["stat", "-c", "%u:%g", dst_file], capture_output=True).strip()
assert owner == "0:0"

output = container.call(["cat", dst_file], capture_output=True)
assert test_binary_data == bytes(output, encoding="utf8", errors="surrogateescape")

Expand All @@ -266,6 +269,12 @@ def test_dir_operations(tmp_path: Path, container_engine):
dst_file = dst_dir / "test.dat"
container.copy_into(test_dir, dst_dir)

owner = container.call(["stat", "-c", "%u:%g", dst_dir], capture_output=True).strip()
assert owner == "0:0"

owner = container.call(["stat", "-c", "%u:%g", dst_file], capture_output=True).strip()
assert owner == "0:0"

output = container.call(["cat", dst_file], capture_output=True)
assert test_binary_data == bytes(output, encoding="utf8", errors="surrogateescape")

Expand All @@ -276,6 +285,11 @@ def test_dir_operations(tmp_path: Path, container_engine):
new_test_dir = tmp_path / "test_dir_new"
container.copy_out(dst_dir, new_test_dir)

assert os.getuid() == new_test_dir.stat().st_uid
assert os.getgid() == new_test_dir.stat().st_gid
assert os.getuid() == (new_test_dir / "test.dat").stat().st_uid
assert os.getgid() == (new_test_dir / "test.dat").stat().st_gid

assert test_binary_data == (new_test_dir / "test.dat").read_bytes()


Expand Down