-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support python_env.pip.uv.enable = true
- Loading branch information
Showing
5 changed files
with
140 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ lib, config, packageSets, ... }: let | ||
cfg = config.pip.uv; | ||
pkgs = packageSets.nixpkgs; | ||
# bug: torch==2.1.0 does not resolve to torch==2.1.0+cpu | ||
patchTorch = builtins.map (y: if builtins.match "torch==[0-9\.]+$" y == [] then "${y}.*" else y); | ||
constraintsArgs = lib.optionals (cfg.constraints != []) [ | ||
"--constraint" | ||
(builtins.toFile "constraints.txt" (lib.concatMapStrings (x: "${x}\n") cfg.constraints)) | ||
]; | ||
overridesArgs = lib.optionals (cfg.overrides != []) [ | ||
"--override" | ||
(builtins.toFile "overrides.txt" (lib.concatMapStrings (x: "${x}\n") cfg.overrides)) | ||
]; | ||
extraArgs = constraintsArgs ++ overridesArgs ++ cfg.extraArgs; | ||
in { | ||
# todo: support env | ||
options.pip.uv = with lib; { | ||
enable = mkEnableOption "use uv solver"; | ||
overrides = mkOption { | ||
type = types.listOf types.str; | ||
default = []; | ||
}; | ||
constraints = mkOption { | ||
type = types.listOf types.str; | ||
default = []; | ||
}; | ||
extraArgs = mkOption { | ||
type = types.listOf types.str; | ||
default = []; | ||
}; | ||
}; | ||
config = lib.mkIf cfg.enable { | ||
deps.fetchPipMetadataScript = pkgs.writeShellScript "fetch-pip-metadata-uv" '' | ||
export UV_DUMP_DREAM2NIX="$out" | ||
${pkgs.uv}/bin/uv pip install \ | ||
--dry-run \ | ||
--reinstall \ | ||
--index-strategy unsafe-highest \ | ||
--break-system-packages \ | ||
${lib.optionalString (config.pip.pypiSnapshotDate != null) "--exclude-newer ${config.pip.pypiSnapshotDate}"} \ | ||
--python ${config.deps.python}/bin/python \ | ||
${lib.escapeShellArgs extraArgs} \ | ||
${lib.escapeShellArgs (patchTorch config.pip.requirementsList)} | ||
''; | ||
lock.invalidationData.solver = "uv"; | ||
lock.invalidationData.extraArgs = extraArgs; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ rustPlatform, fetchFromGitHub, lib, cmake, openssl, pkg-config, perl }: | ||
rustPlatform.buildRustPackage { | ||
pname = "uv"; | ||
version = "0.1.34.post"; | ||
nativeBuildInputs = [ cmake pkg-config perl ]; | ||
buildInputs = [ openssl ]; | ||
src = fetchFromGitHub { | ||
owner = "yorickvP"; | ||
repo = "uv"; | ||
rev = "6ef1d706379a3403d917b75d41697e98f9a0619d"; | ||
hash = "sha256-U4mowALk3XKSzRkhbZT333v3mVlLBpeatl8mwfeg6uw="; | ||
}; | ||
cargoLock = { | ||
lockFile = builtins.fetchurl { | ||
url = "https://raw.githubusercontent.com/astral-sh/uv/6ef1d706379a3403d917b75d41697e98f9a0619d/Cargo.lock"; | ||
sha256 = "12v38b50gyi5g7dz269vl4briw5jffw16mlsmiswh0f6q8nb64q4"; | ||
}; | ||
outputHashes = { | ||
"async_zip-0.0.17" = "sha256-Q5fMDJrQtob54CTII3+SXHeozy5S5s3iLOzntevdGOs="; | ||
"pubgrub-0.2.1" = "sha256-sqC7R2mtqymYFULDW0wSbM/MKCZc8rP7Yy/gaQpjYEI="; | ||
}; | ||
}; | ||
doCheck = false; | ||
} |