Skip to content

Commit 838cf4b

Browse files
Merge pull request #422 from replit/dstewart/chore/uv-bleeding-edge
[uv] uv bleeding edge
2 parents b08d795 + cddc6fd commit 838cf4b

File tree

2 files changed

+89
-1
lines changed

2 files changed

+89
-1
lines changed

pkgs/modules/python/default.nix

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,18 @@ let
9191

9292
sitecustomize = pkgs.callPackage ./sitecustomize.nix { };
9393

94+
uv = pkgs.callPackage ./uv {
95+
rustPlatform = (
96+
let
97+
toolchain = pkgs.fenix.latest.toolchain;
98+
in
99+
pkgs.makeRustPlatform {
100+
cargo = toolchain;
101+
rustc = toolchain;
102+
}
103+
);
104+
};
105+
94106
in
95107
{
96108
id = "python-${pythonVersion}";
@@ -104,7 +116,7 @@ in
104116
binary-wrapped-python
105117
pip-wrapper
106118
poetry-wrapper
107-
pkgs.uv
119+
uv
108120
];
109121

110122
replit.runners.python = {

pkgs/modules/python/uv/default.nix

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{ lib
2+
, stdenv
3+
, cmake
4+
, fetchFromGitHub
5+
, installShellFiles
6+
, pkg-config
7+
, rustPlatform
8+
, versionCheckHook
9+
, python3Packages
10+
, nix-update-script
11+
,
12+
}:
13+
14+
rustPlatform.buildRustPackage rec {
15+
pname = "uv";
16+
version = "0.5.11"; # Technically 8 versions ahead of 0.5.11
17+
18+
src = fetchFromGitHub {
19+
owner = "astral-sh";
20+
repo = "uv";
21+
rev = "ddc290feb4ed2de4740c786af2436cf1f82a3190";
22+
hash = "sha256-/hm70Vptk0eg9MMzgbpkOg/x6mNJBTZ/25kfqiYc/7Y=";
23+
};
24+
25+
useFetchCargoVendor = true;
26+
cargoHash = "sha256-k+ABi0xgtpuDwCEgUIqrG7m56iSeYMsDTvtC0YHoCwE=";
27+
28+
nativeBuildInputs = [
29+
cmake
30+
installShellFiles
31+
pkg-config
32+
];
33+
34+
dontUseCmakeConfigure = true;
35+
36+
RUSTFLAGS = "-Z threads=8";
37+
38+
cargoBuildFlags = [
39+
"--package"
40+
"uv"
41+
];
42+
43+
# Tests require python3
44+
doCheck = false;
45+
46+
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
47+
export HOME=$TMPDIR
48+
installShellCompletion --cmd uv \
49+
--bash <($out/bin/uv --generate-shell-completion bash) \
50+
--fish <($out/bin/uv --generate-shell-completion fish) \
51+
--zsh <($out/bin/uv --generate-shell-completion zsh)
52+
'';
53+
54+
nativeInstallCheckInputs = [
55+
versionCheckHook
56+
];
57+
versionCheckProgramArg = [ "--version" ];
58+
doInstallCheck = true;
59+
60+
passthru = {
61+
tests.uv-python = python3Packages.uv;
62+
updateScript = nix-update-script { };
63+
};
64+
65+
meta = {
66+
description = "Extremely fast Python package installer and resolver, written in Rust";
67+
homepage = "https://github.com/astral-sh/uv";
68+
changelog = "https://github.com/astral-sh/uv/blob/${version}/CHANGELOG.md";
69+
license = with lib.licenses; [
70+
asl20
71+
mit
72+
];
73+
maintainers = with lib.maintainers; [ GaetanLepage ];
74+
mainProgram = "uv";
75+
};
76+
}

0 commit comments

Comments
 (0)