Skip to content

Commit

Permalink
Merge pull request #422 from replit/dstewart/chore/uv-bleeding-edge
Browse files Browse the repository at this point in the history
[uv] uv bleeding edge
  • Loading branch information
blast-hardcheese authored Dec 23, 2024
2 parents b08d795 + cddc6fd commit 838cf4b
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkgs/modules/python/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ let

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

uv = pkgs.callPackage ./uv {
rustPlatform = (
let
toolchain = pkgs.fenix.latest.toolchain;
in
pkgs.makeRustPlatform {
cargo = toolchain;
rustc = toolchain;
}
);
};

in
{
id = "python-${pythonVersion}";
Expand All @@ -104,7 +116,7 @@ in
binary-wrapped-python
pip-wrapper
poetry-wrapper
pkgs.uv
uv
];

replit.runners.python = {
Expand Down
76 changes: 76 additions & 0 deletions pkgs/modules/python/uv/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{ lib
, stdenv
, cmake
, fetchFromGitHub
, installShellFiles
, pkg-config
, rustPlatform
, versionCheckHook
, python3Packages
, nix-update-script
,
}:

rustPlatform.buildRustPackage rec {
pname = "uv";
version = "0.5.11"; # Technically 8 versions ahead of 0.5.11

src = fetchFromGitHub {
owner = "astral-sh";
repo = "uv";
rev = "ddc290feb4ed2de4740c786af2436cf1f82a3190";
hash = "sha256-/hm70Vptk0eg9MMzgbpkOg/x6mNJBTZ/25kfqiYc/7Y=";
};

useFetchCargoVendor = true;
cargoHash = "sha256-k+ABi0xgtpuDwCEgUIqrG7m56iSeYMsDTvtC0YHoCwE=";

nativeBuildInputs = [
cmake
installShellFiles
pkg-config
];

dontUseCmakeConfigure = true;

RUSTFLAGS = "-Z threads=8";

cargoBuildFlags = [
"--package"
"uv"
];

# Tests require python3
doCheck = false;

postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
export HOME=$TMPDIR
installShellCompletion --cmd uv \
--bash <($out/bin/uv --generate-shell-completion bash) \
--fish <($out/bin/uv --generate-shell-completion fish) \
--zsh <($out/bin/uv --generate-shell-completion zsh)
'';

nativeInstallCheckInputs = [
versionCheckHook
];
versionCheckProgramArg = [ "--version" ];
doInstallCheck = true;

passthru = {
tests.uv-python = python3Packages.uv;
updateScript = nix-update-script { };
};

meta = {
description = "Extremely fast Python package installer and resolver, written in Rust";
homepage = "https://github.com/astral-sh/uv";
changelog = "https://github.com/astral-sh/uv/blob/${version}/CHANGELOG.md";
license = with lib.licenses; [
asl20
mit
];
maintainers = with lib.maintainers; [ GaetanLepage ];
mainProgram = "uv";
};
}

0 comments on commit 838cf4b

Please sign in to comment.