at master 1.2 kB view raw
1{ 2 buildPythonPackage, 3 hatchling, 4 lib, 5 ruff, 6}: 7 8buildPythonPackage { 9 inherit (ruff) 10 pname 11 version 12 src 13 meta 14 ; 15 pyproject = true; 16 17 build-system = [ hatchling ]; 18 19 postPatch = 20 # Do not rely on path lookup at runtime to find the ruff binary. 21 # Use the propagated binary instead. 22 '' 23 substituteInPlace python/ruff/__main__.py \ 24 --replace-fail \ 25 'ruff_exe = "ruff" + sysconfig.get_config_var("EXE")' \ 26 'return "${lib.getExe ruff}"' 27 '' 28 # Sidestep the maturin build system in favour of reusing the binary already built by nixpkgs, 29 # to avoid rebuilding the ruff binary for every active python package set. 30 + '' 31 substituteInPlace pyproject.toml \ 32 --replace-fail 'requires = ["maturin>=1.9,<2.0"]' 'requires = ["hatchling"]' \ 33 --replace-fail 'build-backend = "maturin"' 'build-backend = "hatchling.build"' 34 35 cat >> pyproject.toml <<EOF 36 [tool.hatch.build] 37 packages = ['python/ruff'] 38 39 EOF 40 ''; 41 42 postInstall = '' 43 mkdir -p $out/bin && ln -s ${lib.getExe ruff} $out/bin/ruff 44 ''; 45 46 pythonImportsCheck = [ "ruff" ]; 47}