summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaƩtan Lepage <33058747+GaetanLepage@users.noreply.github.com>2025-05-31 23:38:01 +0200
committerGitHub <noreply@github.com>2025-05-31 23:38:01 +0200
commit2ce7ae3329f8e35562da6ef4d98d740415612146 (patch)
treea985d657b673dd29fc3a6a63173b61f56516dbfe
parentyetris: fix compilation on aarch64-linux (#412563) (diff)
parentpython3Packages.uv: reuse already built uv binary (diff)
downloadnixpkgs-2ce7ae3329f8e35562da6ef4d98d740415612146.tar.gz
python3Packages.uv: reuse already built uv binary (#412206)
-rw-r--r--pkgs/development/python-modules/uv/default.nix49
-rw-r--r--pkgs/top-level/python-packages.nix2
2 files changed, 30 insertions, 21 deletions
diff --git a/pkgs/development/python-modules/uv/default.nix b/pkgs/development/python-modules/uv/default.nix
index 726a861372db..2ab81cf60602 100644
--- a/pkgs/development/python-modules/uv/default.nix
+++ b/pkgs/development/python-modules/uv/default.nix
@@ -1,36 +1,45 @@
{
buildPythonPackage,
- installShellFiles,
- rustPlatform,
- pkgs,
- versionCheckHook,
+ hatchling,
+ lib,
+ uv,
}:
buildPythonPackage {
- inherit (pkgs.uv)
+ inherit (uv)
pname
version
src
- cargoDeps
meta
- cargoBuildFlags
- postInstall
- versionCheckProgramArg
;
+ pyproject = true;
- postPatch = ''
- substituteInPlace python/uv/_find_uv.py \
- --replace-fail '"""Return the uv binary path."""' "return '$out/bin/uv'"
- '';
+ build-system = [ hatchling ];
- nativeBuildInputs = [
- installShellFiles
- rustPlatform.cargoSetupHook
- rustPlatform.maturinBuildHook
- ];
+ postPatch =
+ # Do not rely on path lookup at runtime to find the uv binary.
+ # Use the propagated binary instead.
+ ''
+ substituteInPlace python/uv/_find_uv.py \
+ --replace-fail '"""Return the uv binary path."""' "return '${lib.getExe uv}'"
+ ''
+ # Sidestep the maturin build system in favour of reusing the binary already built by nixpkgs,
+ # to avoid rebuilding the uv binary for every active python package set.
+ + ''
+ substituteInPlace pyproject.toml \
+ --replace-fail 'requires = ["maturin>=1.0,<2.0"]' 'requires = ["hatchling"]' \
+ --replace-fail 'build-backend = "maturin"' 'build-backend = "hatchling.build"'
- nativeCheckInputs = [ versionCheckHook ];
+ cat >> pyproject.toml <<EOF
+ [tool.hatch.build]
+ packages = ['python/uv']
+
+ EOF
+ '';
+
+ postInstall = ''
+ mkdir -p $out/bin && ln -s ${lib.getExe uv} $out/bin/uv
+ '';
- pyproject = true;
pythonImportsCheck = [ "uv" ];
}
diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix
index c81f03a31d53..c4c9004ae04d 100644
--- a/pkgs/top-level/python-packages.nix
+++ b/pkgs/top-level/python-packages.nix
@@ -18674,7 +18674,7 @@ self: super: with self; {
uuid6 = callPackage ../development/python-modules/uuid6 { };
- uv = callPackage ../development/python-modules/uv { };
+ uv = callPackage ../development/python-modules/uv { inherit (pkgs) uv; };
uv-build = callPackage ../development/python-modules/uv-build { };