mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-06 01:31:39 -05:00
feat: add changelog files to fixup hook
This commit is contained in:
parent
aed88688ec
commit
f9befdc387
1 changed files with 93 additions and 75 deletions
|
@ -6,6 +6,7 @@
|
|||
, pip
|
||||
, pkgs
|
||||
, lib
|
||||
,
|
||||
}:
|
||||
let
|
||||
inherit (python.pythonForBuild.pkgs) callPackage;
|
||||
|
@ -13,7 +14,11 @@ let
|
|||
pythonSitePackages = python.sitePackages;
|
||||
|
||||
nonOverlayedPython = pkgs.python3.pythonForBuild.withPackages (ps: [ ps.tomlkit ]);
|
||||
makeRemoveSpecialDependenciesHook = { fields, kind }:
|
||||
makeRemoveSpecialDependenciesHook =
|
||||
{ fields
|
||||
, kind
|
||||
,
|
||||
}:
|
||||
nonOverlayedPython.pkgs.callPackage
|
||||
(
|
||||
_:
|
||||
|
@ -29,14 +34,14 @@ let
|
|||
inherit fields;
|
||||
inherit kind;
|
||||
};
|
||||
} ./remove-special-dependencies.sh
|
||||
}
|
||||
./remove-special-dependencies.sh
|
||||
)
|
||||
{ };
|
||||
makeSetupHookArgs = deps:
|
||||
if lib.elem "propagatedBuildInputs" (builtins.attrNames (builtins.functionArgs makeSetupHook)) then
|
||||
{ propagatedBuildInputs = deps; }
|
||||
else
|
||||
{ inherit deps; };
|
||||
if lib.elem "propagatedBuildInputs" (builtins.attrNames (builtins.functionArgs makeSetupHook))
|
||||
then { propagatedBuildInputs = deps; }
|
||||
else { inherit deps; };
|
||||
in
|
||||
{
|
||||
removePathDependenciesHook = makeRemoveSpecialDependenciesHook {
|
||||
|
@ -49,84 +54,97 @@ in
|
|||
kind = "git";
|
||||
};
|
||||
|
||||
pipBuildHook =
|
||||
callPackage
|
||||
(
|
||||
{ pip
|
||||
, wheel
|
||||
,
|
||||
}:
|
||||
makeSetupHook
|
||||
({
|
||||
name = "pip-build-hook.sh";
|
||||
substitutions = {
|
||||
inherit pythonInterpreter pythonSitePackages;
|
||||
};
|
||||
}
|
||||
// (makeSetupHookArgs [ pip wheel ]))
|
||||
./pip-build-hook.sh
|
||||
)
|
||||
{ };
|
||||
|
||||
pipBuildHook = callPackage
|
||||
(
|
||||
{ pip, wheel }:
|
||||
makeSetupHook
|
||||
({
|
||||
name = "pip-build-hook.sh";
|
||||
substitutions = {
|
||||
inherit pythonInterpreter pythonSitePackages;
|
||||
};
|
||||
} // (makeSetupHookArgs [ pip wheel ])) ./pip-build-hook.sh
|
||||
)
|
||||
{ };
|
||||
|
||||
poetry2nixFixupHook = callPackage
|
||||
(
|
||||
_:
|
||||
makeSetupHook
|
||||
{
|
||||
name = "fixup-hook.sh";
|
||||
substitutions = {
|
||||
inherit pythonSitePackages;
|
||||
filenames = builtins.concatStringsSep " " [
|
||||
"pyproject.toml"
|
||||
"README.md"
|
||||
"LICENSE"
|
||||
];
|
||||
};
|
||||
} ./fixup-hook.sh
|
||||
)
|
||||
{ };
|
||||
poetry2nixFixupHook =
|
||||
callPackage
|
||||
(
|
||||
_:
|
||||
makeSetupHook
|
||||
{
|
||||
name = "fixup-hook.sh";
|
||||
substitutions = {
|
||||
inherit pythonSitePackages;
|
||||
filenames = builtins.concatStringsSep " " [
|
||||
"pyproject.toml"
|
||||
"README.md"
|
||||
"LICENSE"
|
||||
"CHANGELOG.md"
|
||||
"CHANGES.md"
|
||||
];
|
||||
};
|
||||
}
|
||||
./fixup-hook.sh
|
||||
)
|
||||
{ };
|
||||
|
||||
# As of 2023-03 a newer version of packaging introduced a new behaviour where python-requires
|
||||
# cannot contain version wildcards. This behaviour is complaint with PEP440
|
||||
#
|
||||
# The wildcards are a no-op anyway so we can work around this issue by just dropping the precision down to the last known number.
|
||||
poetry2nixPythonRequiresPatchHook = callPackage
|
||||
(
|
||||
_:
|
||||
let
|
||||
# Python pre 3.9 does not contain the ast.unparse method.
|
||||
# We can extract this from Python 3.8 for any
|
||||
unparser = stdenv.mkDerivation {
|
||||
name = "${python.name}-astunparse";
|
||||
inherit (python) src;
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
poetry2nixPythonRequiresPatchHook =
|
||||
callPackage
|
||||
(
|
||||
_:
|
||||
let
|
||||
# Python pre 3.9 does not contain the ast.unparse method.
|
||||
# We can extract this from Python 3.8 for any
|
||||
unparser = stdenv.mkDerivation {
|
||||
name = "${python.name}-astunparse";
|
||||
inherit (python) src;
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/poetry2nix_astunparse
|
||||
cp ./Tools/parser/unparse.py $out/poetry2nix_astunparse/__init__.py
|
||||
'';
|
||||
};
|
||||
|
||||
pythonPath =
|
||||
[ ]
|
||||
++ lib.optional (lib.versionOlder python.version "3.9") unparser;
|
||||
|
||||
in
|
||||
makeSetupHook
|
||||
{
|
||||
name = "require-python-patch-hook.sh";
|
||||
substitutions = {
|
||||
inherit pythonInterpreter pythonPath;
|
||||
patchScript = ./python-requires-patch-hook.py;
|
||||
installPhase = ''
|
||||
mkdir -p $out/poetry2nix_astunparse
|
||||
cp ./Tools/parser/unparse.py $out/poetry2nix_astunparse/__init__.py
|
||||
'';
|
||||
};
|
||||
} ./python-requires-patch-hook.sh
|
||||
)
|
||||
{ };
|
||||
|
||||
pythonPath =
|
||||
[ ]
|
||||
++ lib.optional (lib.versionOlder python.version "3.9") unparser;
|
||||
in
|
||||
makeSetupHook
|
||||
{
|
||||
name = "require-python-patch-hook.sh";
|
||||
substitutions = {
|
||||
inherit pythonInterpreter pythonPath;
|
||||
patchScript = ./python-requires-patch-hook.py;
|
||||
};
|
||||
}
|
||||
./python-requires-patch-hook.sh
|
||||
)
|
||||
{ };
|
||||
|
||||
# When the "wheel" package itself is a wheel the nixpkgs hook (which pulls in "wheel") leads to infinite recursion
|
||||
# It doesn't _really_ depend on wheel though, it just copies the wheel.
|
||||
wheelUnpackHook = callPackage
|
||||
(_:
|
||||
makeSetupHook
|
||||
{
|
||||
name = "wheel-unpack-hook.sh";
|
||||
} ./wheel-unpack-hook.sh
|
||||
)
|
||||
{ };
|
||||
wheelUnpackHook =
|
||||
callPackage
|
||||
(
|
||||
_:
|
||||
makeSetupHook
|
||||
{
|
||||
name = "wheel-unpack-hook.sh";
|
||||
}
|
||||
./wheel-unpack-hook.sh
|
||||
)
|
||||
{ };
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue