diff options
author | adisbladis <adisbladis@gmail.com> | 2020-01-08 13:29:03 +0000 |
---|---|---|
committer | adisbladis <adisbladis@gmail.com> | 2020-01-08 13:59:04 +0000 |
commit | 2d6f1ff4dd2ce208fce624466b4eeae54eafd61f (patch) | |
tree | 4c10fda6b6e45505f9845ceb80725c63a3ebbd26 /pkgs | |
parent | 380220c237d479b81182884afec76e77685e9a36 (diff) | |
download | nixlib-2d6f1ff4dd2ce208fce624466b4eeae54eafd61f.tar nixlib-2d6f1ff4dd2ce208fce624466b4eeae54eafd61f.tar.gz nixlib-2d6f1ff4dd2ce208fce624466b4eeae54eafd61f.tar.bz2 nixlib-2d6f1ff4dd2ce208fce624466b4eeae54eafd61f.tar.lz nixlib-2d6f1ff4dd2ce208fce624466b4eeae54eafd61f.tar.xz nixlib-2d6f1ff4dd2ce208fce624466b4eeae54eafd61f.tar.zst nixlib-2d6f1ff4dd2ce208fce624466b4eeae54eafd61f.zip |
python: Add support for installing Python eggs
Diffstat (limited to 'pkgs')
6 files changed, 80 insertions, 1 deletions
diff --git a/pkgs/development/interpreters/python/hooks/default.nix b/pkgs/development/interpreters/python/hooks/default.nix index 861cb38c0607..f05b3b1eec63 100644 --- a/pkgs/development/interpreters/python/hooks/default.nix +++ b/pkgs/development/interpreters/python/hooks/default.nix @@ -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"; diff --git a/pkgs/development/interpreters/python/hooks/egg-build-hook.sh b/pkgs/development/interpreters/python/hooks/egg-build-hook.sh new file mode 100644 index 000000000000..d5abc8d55e5a --- /dev/null +++ b/pkgs/development/interpreters/python/hooks/egg-build-hook.sh @@ -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 diff --git a/pkgs/development/interpreters/python/hooks/egg-install-hook.sh b/pkgs/development/interpreters/python/hooks/egg-install-hook.sh new file mode 100644 index 000000000000..ae894fb1bde4 --- /dev/null +++ b/pkgs/development/interpreters/python/hooks/egg-install-hook.sh @@ -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 diff --git a/pkgs/development/interpreters/python/hooks/egg-unpack-hook.sh b/pkgs/development/interpreters/python/hooks/egg-unpack-hook.sh new file mode 100644 index 000000000000..c8ed3dee83ba --- /dev/null +++ b/pkgs/development/interpreters/python/hooks/egg-unpack-hook.sh @@ -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 diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index 700894eda6de..020298cc8e9f 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -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) [ diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 4ce723bfa5d0..6215349c2f76 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -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 |