python: Add support for installing Python eggs
This commit is contained in:
parent
380220c237
commit
2d6f1ff4dd
@ -821,6 +821,9 @@ should be used with `ignoreCollisions = true`.
|
|||||||
The following are setup hooks specifically for Python packages. Most of these are
|
The following are setup hooks specifically for Python packages. Most of these are
|
||||||
used in `buildPythonPackage`.
|
used in `buildPythonPackage`.
|
||||||
|
|
||||||
|
- `eggUnpackhook` to move an egg to the correct folder so it can be installed with the `eggInstallHook`
|
||||||
|
- `eggBuildHook` to skip building for eggs.
|
||||||
|
- `eggInstallHook` to install eggs.
|
||||||
- `flitBuildHook` to build a wheel using `flit`.
|
- `flitBuildHook` to build a wheel using `flit`.
|
||||||
- `pipBuildHook` to build a wheel using `pip` and PEP 517. Note a build system (e.g. `setuptools` or `flit`) should still be added as `nativeBuildInput`.
|
- `pipBuildHook` to build a wheel using `pip` and PEP 517. Note a build system (e.g. `setuptools` or `flit`) should still be added as `nativeBuildInput`.
|
||||||
- `pipInstallHook` to install wheels.
|
- `pipInstallHook` to install wheels.
|
||||||
|
@ -11,6 +11,27 @@ let
|
|||||||
setuppy = ../run_setup.py;
|
setuppy = ../run_setup.py;
|
||||||
in rec {
|
in rec {
|
||||||
|
|
||||||
|
eggBuildHook = callPackage ({ }:
|
||||||
|
makeSetupHook {
|
||||||
|
name = "egg-build-hook.sh";
|
||||||
|
deps = [ ];
|
||||||
|
} ./egg-build-hook.sh) {};
|
||||||
|
|
||||||
|
eggInstallHook = callPackage ({ setuptools }:
|
||||||
|
makeSetupHook {
|
||||||
|
name = "egg-install-hook.sh";
|
||||||
|
deps = [ setuptools ];
|
||||||
|
substitutions = {
|
||||||
|
inherit pythonInterpreter pythonSitePackages;
|
||||||
|
};
|
||||||
|
} ./egg-install-hook.sh) {};
|
||||||
|
|
||||||
|
eggUnpackHook = callPackage ({ }:
|
||||||
|
makeSetupHook {
|
||||||
|
name = "egg-unpack-hook.sh";
|
||||||
|
deps = [ ];
|
||||||
|
} ./egg-unpack-hook.sh) {};
|
||||||
|
|
||||||
flitBuildHook = callPackage ({ flit }:
|
flitBuildHook = callPackage ({ flit }:
|
||||||
makeSetupHook {
|
makeSetupHook {
|
||||||
name = "flit-build-hook";
|
name = "flit-build-hook";
|
||||||
|
15
pkgs/development/interpreters/python/hooks/egg-build-hook.sh
Normal file
15
pkgs/development/interpreters/python/hooks/egg-build-hook.sh
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Setup hook to use for eggs
|
||||||
|
echo "Sourcing egg-build-hook"
|
||||||
|
|
||||||
|
eggBuildPhase() {
|
||||||
|
echo "Executing eggBuildPhase"
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
echo "Finished executing eggBuildPhase"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "${dontUseEggBuild-}" ] && [ -z "${buildPhase-}" ]; then
|
||||||
|
echo "Using eggBuildPhase"
|
||||||
|
buildPhase=eggBuildPhase
|
||||||
|
fi
|
@ -0,0 +1,21 @@
|
|||||||
|
# Setup hook for eggs
|
||||||
|
echo "Sourcing egg-install-hook"
|
||||||
|
|
||||||
|
eggInstallPhase() {
|
||||||
|
echo "Executing eggInstallPhase"
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
mkdir -p "$out/@pythonSitePackages@"
|
||||||
|
export PYTHONPATH="$out/@pythonSitePackages@:$PYTHONPATH"
|
||||||
|
|
||||||
|
find
|
||||||
|
@pythonInterpreter@ -m easy_install --prefix="$out" *.egg
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
echo "Finished executing eggInstallPhase"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "${dontUseEggInstall-}" ] && [ -z "${installPhase-}" ]; then
|
||||||
|
echo "Using eggInstallPhase"
|
||||||
|
installPhase=eggInstallPhase
|
||||||
|
fi
|
@ -0,0 +1,17 @@
|
|||||||
|
# Setup hook to use in case an egg is fetched
|
||||||
|
echo "Sourcing egg setup hook"
|
||||||
|
|
||||||
|
eggUnpackPhase(){
|
||||||
|
echo "Executing eggUnpackPhase"
|
||||||
|
runHook preUnpack
|
||||||
|
|
||||||
|
cp "$src" "$(stripHash "$src")"
|
||||||
|
|
||||||
|
# runHook postUnpack # Calls find...?
|
||||||
|
echo "Finished executing eggUnpackPhase"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "${dontUseEggUnpack-}" ] && [ -z "${unpackPhase-}" ]; then
|
||||||
|
echo "Using eggUnpackPhase"
|
||||||
|
unpackPhase=eggUnpackPhase
|
||||||
|
fi
|
@ -20,6 +20,9 @@
|
|||||||
, setuptoolsBuildHook
|
, setuptoolsBuildHook
|
||||||
, setuptoolsCheckHook
|
, setuptoolsCheckHook
|
||||||
, wheelUnpackHook
|
, wheelUnpackHook
|
||||||
|
, eggUnpackHook
|
||||||
|
, eggBuildHook
|
||||||
|
, eggInstallHook
|
||||||
}:
|
}:
|
||||||
|
|
||||||
{ name ? "${attrs.pname}-${attrs.version}"
|
{ name ? "${attrs.pname}-${attrs.version}"
|
||||||
@ -119,6 +122,8 @@ let
|
|||||||
pipBuildHook
|
pipBuildHook
|
||||||
] ++ lib.optionals (format == "wheel") [
|
] ++ lib.optionals (format == "wheel") [
|
||||||
wheelUnpackHook
|
wheelUnpackHook
|
||||||
|
] ++ lib.optionals (format == "egg") [
|
||||||
|
eggUnpackHook eggBuildHook eggInstallHook
|
||||||
] ++ lib.optionals (!(format == "other") || dontUsePipInstall) [
|
] ++ lib.optionals (!(format == "other") || dontUsePipInstall) [
|
||||||
pipInstallHook
|
pipInstallHook
|
||||||
] ++ lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [
|
] ++ lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [
|
||||||
|
@ -108,7 +108,7 @@ in {
|
|||||||
inherit buildSetupcfg;
|
inherit buildSetupcfg;
|
||||||
|
|
||||||
inherit (callPackage ../development/interpreters/python/hooks { })
|
inherit (callPackage ../development/interpreters/python/hooks { })
|
||||||
flitBuildHook pipBuildHook pipInstallHook pytestCheckHook pythonCatchConflictsHook pythonImportsCheckHook pythonRemoveBinBytecodeHook setuptoolsBuildHook setuptoolsCheckHook wheelUnpackHook;
|
eggUnpackHook eggBuildHook eggInstallHook flitBuildHook pipBuildHook pipInstallHook pytestCheckHook pythonCatchConflictsHook pythonImportsCheckHook pythonRemoveBinBytecodeHook setuptoolsBuildHook setuptoolsCheckHook wheelUnpackHook;
|
||||||
|
|
||||||
# helpers
|
# helpers
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user