Skip to content

Commit b0c229f

Browse files
committed
Fix maturin installation to use uv pip in uv-managed environments
The build hook now checks for uv and uses 'uv pip install maturin' instead of 'python -m pip install maturin' when uv is available. This fixes the build failure in GitHub Actions where uv manages the Python environment.
1 parent 05e2b0b commit b0c229f

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

hatch_build.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,19 @@ def _build_rust_extension(self, here: Path, *, required: bool = False) -> bool:
4242
# Check if maturin is available
4343
if not shutil.which("maturin"):
4444
try:
45-
subprocess.run(
46-
[sys.executable, "-m", "pip", "install", "maturin"],
47-
check=True,
48-
capture_output=True,
49-
)
45+
# Try uv pip first, fall back to pip
46+
if shutil.which("uv"):
47+
subprocess.run(
48+
["uv", "pip", "install", "maturin"],
49+
check=True,
50+
capture_output=True,
51+
)
52+
else:
53+
subprocess.run(
54+
[sys.executable, "-m", "pip", "install", "maturin"],
55+
check=True,
56+
capture_output=True,
57+
)
5058
except subprocess.CalledProcessError as e:
5159
msg = f"Failed to install maturin: {e}"
5260
if required:

0 commit comments

Comments
 (0)