diff --git a/default.nix b/default.nix index 52373e7..4ef35a6 100644 --- a/default.nix +++ b/default.nix @@ -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 diff --git a/hooks/default.nix b/hooks/default.nix index dd24b26..ec3fa0a 100644 --- a/hooks/default.nix +++ b/hooks/default.nix @@ -22,4 +22,12 @@ in } ./remove-path-dependencies.sh ) {}; + poetry2nixFixupHook = callPackage ( + {}: + makeSetupHook { + name = "fixup-hook.sh"; + deps = []; + } ./fixup-hook.sh + ) {}; + } diff --git a/hooks/fixup-hook.sh b/hooks/fixup-hook.sh new file mode 100644 index 0000000..fc539e4 --- /dev/null +++ b/hooks/fixup-hook.sh @@ -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) diff --git a/mk-poetry-dep.nix b/mk-poetry-dep.nix index 2caa383..7a8975b 100644 --- a/mk-poetry-dep.nix +++ b/mk-poetry-dep.nix @@ -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 ;