python: Add support for installing Python eggs

wip/yesman
adisbladis 4 years ago
parent 380220c237
commit 2d6f1ff4dd
No known key found for this signature in database
GPG Key ID: 110BFAD44C6249B7
  1. 3
      doc/languages-frameworks/python.section.md
  2. 21
      pkgs/development/interpreters/python/hooks/default.nix
  3. 15
      pkgs/development/interpreters/python/hooks/egg-build-hook.sh
  4. 21
      pkgs/development/interpreters/python/hooks/egg-install-hook.sh
  5. 17
      pkgs/development/interpreters/python/hooks/egg-unpack-hook.sh
  6. 5
      pkgs/development/interpreters/python/mk-python-derivation.nix
  7. 2
      pkgs/top-level/python-packages.nix

@ -821,6 +821,9 @@ should be used with `ignoreCollisions = true`.
The following are setup hooks specifically for Python packages. Most of these are
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`.
- `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.

@ -11,6 +11,27 @@ let
setuppy = ../run_setup.py;
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 }:
makeSetupHook {
name = "flit-build-hook";

@ -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
, setuptoolsCheckHook
, wheelUnpackHook
, eggUnpackHook
, eggBuildHook
, eggInstallHook
}:
{ name ? "${attrs.pname}-${attrs.version}"
@ -119,6 +122,8 @@ let
pipBuildHook
] ++ lib.optionals (format == "wheel") [
wheelUnpackHook
] ++ lib.optionals (format == "egg") [
eggUnpackHook eggBuildHook eggInstallHook
] ++ lib.optionals (!(format == "other") || dontUsePipInstall) [
pipInstallHook
] ++ lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [

@ -108,7 +108,7 @@ in {
inherit buildSetupcfg;
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

Loading…
Cancel
Save