nixpkgs/pkgs/development/python-modules/ruff/default.nix
Benjamin Sparks 1d4f0fd18c ruff: 0.15.2 -> 0.15.3
Changelog: https://github.com/astral-sh/ruff/releases/tag/0.15.3

Since ruff 0.15.2, the `find_ruff_bin` routine now lives in `_find_ruff.py`
2026-02-26 17:53:34 +01:00

47 lines
1.1 KiB
Nix

{
buildPythonPackage,
hatchling,
lib,
ruff,
}:
buildPythonPackage {
inherit (ruff)
pname
version
src
meta
;
pyproject = true;
build-system = [ hatchling ];
postPatch =
# Do not rely on path lookup at runtime to find the ruff binary.
# Use the propagated binary instead.
''
substituteInPlace python/ruff/_find_ruff.py \
--replace-fail \
'ruff_exe = "ruff" + sysconfig.get_config_var("EXE")' \
'return "${lib.getExe ruff}"'
''
# Sidestep the maturin build system in favour of reusing the binary already built by nixpkgs,
# to avoid rebuilding the ruff binary for every active python package set.
+ ''
substituteInPlace pyproject.toml \
--replace-fail 'requires = ["maturin>=1.9,<2.0"]' 'requires = ["hatchling"]' \
--replace-fail 'build-backend = "maturin"' 'build-backend = "hatchling.build"'
cat >> pyproject.toml <<EOF
[tool.hatch.build]
packages = ['python/ruff']
EOF
'';
postInstall = ''
mkdir -p $out/bin && ln -s ${lib.getExe ruff} $out/bin/ruff
'';
pythonImportsCheck = [ "ruff" ];
}