Add fixup hook

This hook should fix common mistakes like installing `tests` in
site-packages which leads to collisions.
This commit is contained in:
adisbladis 2020-02-28 19:45:23 +00:00
parent c1b21de0ba
commit 090e2dd957
No known key found for this signature in database
GPG key ID: 110BFAD44C6249B7
4 changed files with 21 additions and 3 deletions

View file

@ -99,7 +99,7 @@ let
# The canonical name is setuptools-scm
setuptools-scm = super.setuptools_scm;
inherit (hooks) removePathDependenciesHook;
inherit (hooks) removePathDependenciesHook poetry2nixFixupHook;
}
)
# Null out any filtered packages, we don't want python.pkgs from nixpkgs

View file

@ -22,4 +22,12 @@ in
} ./remove-path-dependencies.sh
) {};
poetry2nixFixupHook = callPackage (
{}:
makeSetupHook {
name = "fixup-hook.sh";
deps = [];
} ./fixup-hook.sh
) {};
}

8
hooks/fixup-hook.sh Normal file
View file

@ -0,0 +1,8 @@
poetry2nix-fixup-hook() {
# Including tests in the output is a common mistake
if [ -z "${dontFixupTests-}" ]; then
rm -rf $out/lib/python3.7/site-packages/tests
fi
}
postFixupHooks+=(poetry2nix-fixup-hook)

View file

@ -106,8 +106,10 @@ pythonPackages.callPackage (
# Stripping pre-built wheels lead to `ELF load command address/offset not properly aligned`
dontStrip = format == "wheel";
nativeBuildInputs = (if (!isSource && (getManyLinuxDeps fileInfo.name).str != null) then [ autoPatchelfHook ] else [])
++ lib.optional (isLocal) pkgs.yj
nativeBuildInputs = [
pythonPackages.poetry2nixFixupHook
]
++ lib.optional (!isSource && (getManyLinuxDeps fileInfo.name).str != null) autoPatchelfHook
++ lib.optional (format == "pyproject") pythonPackages.removePathDependenciesHook
;