mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-10-02 21:10:08 +00:00
uv: Build as a standalone without Python
Using `buildPythonPackage` triggers dependency propagation, meaning that using `uv` with `nix-shell` results in a a shell with the `uv` Python input in it. This is problematic for development usage where you only want the one specified version. Often this design bug in the Python package builders is worked around by deleting `$out/nix-support/propagated-build-inputs`, but since `uv` is written in Rust and can be built without a Python interpreter so it's better to just build without a Python interpreter.
This commit is contained in:
@@ -4,16 +4,14 @@
|
||||
fetchFromGitHub,
|
||||
installShellFiles,
|
||||
pkg-config,
|
||||
python3Packages,
|
||||
rustPlatform,
|
||||
versionCheckHook,
|
||||
nix-update-script,
|
||||
}:
|
||||
|
||||
python3Packages.buildPythonApplication rec {
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "uv";
|
||||
version = "0.5.4";
|
||||
pyproject = true;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "astral-sh";
|
||||
@@ -22,17 +20,13 @@ python3Packages.buildPythonApplication rec {
|
||||
hash = "sha256-Kieh76RUrDEwdL04mvCXOqbXHasMMpXRqp0LwMOIHdM=";
|
||||
};
|
||||
|
||||
cargoDeps = rustPlatform.fetchCargoVendor {
|
||||
inherit pname version src;
|
||||
hash = "sha256-ZhHUKotXVDdwJs2kqIxME5I1FitWetx7FrQtluuIUWo=";
|
||||
};
|
||||
useFetchCargoVendor = true;
|
||||
cargoHash = "sha256-ZhHUKotXVDdwJs2kqIxME5I1FitWetx7FrQtluuIUWo=";
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
installShellFiles
|
||||
pkg-config
|
||||
rustPlatform.cargoSetupHook
|
||||
rustPlatform.maturinBuildHook
|
||||
];
|
||||
|
||||
dontUseCmakeConfigure = true;
|
||||
@@ -42,6 +36,8 @@ python3Packages.buildPythonApplication rec {
|
||||
"uv"
|
||||
];
|
||||
|
||||
doCheck = false;
|
||||
|
||||
postInstall = ''
|
||||
export HOME=$TMPDIR
|
||||
installShellCompletion --cmd uv \
|
||||
@@ -50,8 +46,6 @@ python3Packages.buildPythonApplication rec {
|
||||
--zsh <($out/bin/uv --generate-shell-completion zsh)
|
||||
'';
|
||||
|
||||
pythonImportsCheck = [ "uv" ];
|
||||
|
||||
nativeCheckInputs = [
|
||||
versionCheckHook
|
||||
];
|
||||
|
||||
32
pkgs/development/python-modules/uv/default.nix
Normal file
32
pkgs/development/python-modules/uv/default.nix
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
buildPythonPackage,
|
||||
installShellFiles,
|
||||
pkg-config,
|
||||
rustPlatform,
|
||||
pkgs,
|
||||
}:
|
||||
|
||||
buildPythonPackage {
|
||||
inherit (pkgs.uv)
|
||||
pname
|
||||
version
|
||||
src
|
||||
cargoDeps
|
||||
dontUseCmakeConfigure
|
||||
meta
|
||||
cargoBuildFlags
|
||||
postInstall
|
||||
versionCheckProgramArg
|
||||
;
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkgs.cmake
|
||||
installShellFiles
|
||||
pkg-config
|
||||
rustPlatform.cargoSetupHook
|
||||
rustPlatform.maturinBuildHook
|
||||
];
|
||||
|
||||
pyproject = true;
|
||||
pythonImportsCheck = [ "uv" ];
|
||||
}
|
||||
@@ -17395,9 +17395,7 @@ self: super: with self; {
|
||||
|
||||
uuid6 = callPackage ../development/python-modules/uuid6 { };
|
||||
|
||||
uv = toPythonModule (pkgs.uv.override {
|
||||
python3Packages = self;
|
||||
});
|
||||
uv = callPackage ../development/python-modules/uv { };
|
||||
|
||||
uvcclient = callPackage ../development/python-modules/uvcclient { };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user