at master 1.2 kB view raw
1{ 2 buildPythonPackage, 3 hatchling, 4 lib, 5 uv, 6}: 7 8buildPythonPackage { 9 inherit (uv) 10 pname 11 version 12 src 13 meta 14 ; 15 pyproject = true; 16 17 build-system = [ hatchling ]; 18 19 postPatch = 20 # Add the path to the uv binary as a fallback after other path search methods have been exhausted 21 '' 22 substituteInPlace python/uv/_find_uv.py \ 23 --replace-fail \ 24 'sysconfig.get_path("scripts", scheme=_user_scheme()),' \ 25 'sysconfig.get_path("scripts", scheme=_user_scheme()), "${builtins.baseNameOf (lib.getExe uv)}",' 26 '' 27 # Sidestep the maturin build system in favour of reusing the binary already built by nixpkgs, 28 # to avoid rebuilding the uv binary for every active python package set. 29 + '' 30 substituteInPlace pyproject.toml \ 31 --replace-fail 'requires = ["maturin>=1.0,<2.0"]' 'requires = ["hatchling"]' \ 32 --replace-fail 'build-backend = "maturin"' 'build-backend = "hatchling.build"' 33 34 cat >> pyproject.toml <<EOF 35 [tool.hatch.build] 36 packages = ['python/uv'] 37 38 EOF 39 ''; 40 41 postInstall = '' 42 mkdir -p $out/bin && ln -s ${lib.getExe uv} $out/bin/uv 43 ''; 44 45 pythonImportsCheck = [ "uv" ]; 46}