mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00
python3Packages.ruff: reuse already built ruff binary (#412112)
This commit is contained in:
commit
f00c0c85f3
1 changed files with 30 additions and 18 deletions
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
buildPythonPackage,
|
buildPythonPackage,
|
||||||
|
hatchling,
|
||||||
|
lib,
|
||||||
ruff,
|
ruff,
|
||||||
rustPlatform,
|
|
||||||
installShellFiles,
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
buildPythonPackage {
|
buildPythonPackage {
|
||||||
|
@ -10,26 +10,38 @@ buildPythonPackage {
|
||||||
pname
|
pname
|
||||||
version
|
version
|
||||||
src
|
src
|
||||||
cargoDeps
|
|
||||||
postInstall
|
|
||||||
meta
|
meta
|
||||||
;
|
;
|
||||||
|
|
||||||
# Do not rely on path lookup at runtime to find the ruff binary
|
|
||||||
postPatch = ''
|
|
||||||
substituteInPlace python/ruff/__main__.py \
|
|
||||||
--replace-fail \
|
|
||||||
'ruff_exe = "ruff" + sysconfig.get_config_var("EXE")' \
|
|
||||||
'return "${placeholder "out"}/bin/ruff"'
|
|
||||||
'';
|
|
||||||
|
|
||||||
pyproject = true;
|
pyproject = true;
|
||||||
|
|
||||||
nativeBuildInputs = [
|
build-system = [ hatchling ];
|
||||||
installShellFiles
|
|
||||||
rustPlatform.cargoSetupHook
|
postPatch =
|
||||||
rustPlatform.maturinBuildHook
|
# Do not rely on path lookup at runtime to find the ruff binary.
|
||||||
];
|
# Use the propagated binary instead.
|
||||||
|
''
|
||||||
|
substituteInPlace python/ruff/__main__.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.0,<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" ];
|
pythonImportsCheck = [ "ruff" ];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue