diff options
Diffstat (limited to 'pkgs/development/interpreters/python')
9 files changed, 139 insertions, 5 deletions
diff --git a/pkgs/development/interpreters/python/default.nix b/pkgs/development/interpreters/python/default.nix index caf2e13bdf6..4811c8ec48e 100644 --- a/pkgs/development/interpreters/python/default.nix +++ b/pkgs/development/interpreters/python/default.nix @@ -158,9 +158,11 @@ in { }; sha256 = "0yq6ln1ic476sasp8zs4mg5i9524l1p96qwanp486rr1yza1grlg"; pythonVersion = "2.7"; - db = db.override { dbmSupport = true; }; + db = db.override { dbmSupport = !stdenv.isDarwin; }; python = python27; inherit passthruFun; + inherit (darwin) libunwind; + inherit (darwin.apple_sdk.frameworks) Security; }; pypy36 = callPackage ./pypy { @@ -172,9 +174,11 @@ in { }; sha256 = "1hqvnran7d2dzj5555n7q680dyzhmbklz04pvkxgb5j604v7kkx1"; pythonVersion = "3.6"; - db = db.override { dbmSupport = true; }; + db = db.override { dbmSupport = !stdenv.isDarwin; }; python = python27; inherit passthruFun; + inherit (darwin) libunwind; + inherit (darwin.apple_sdk.frameworks) Security; }; pypy27_prebuilt = callPackage ./pypy/prebuilt.nix { diff --git a/pkgs/development/interpreters/python/hooks/default.nix b/pkgs/development/interpreters/python/hooks/default.nix index 861cb38c060..159637ae9d5 100644 --- a/pkgs/development/interpreters/python/hooks/default.nix +++ b/pkgs/development/interpreters/python/hooks/default.nix @@ -2,6 +2,9 @@ { python , callPackage , makeSetupHook +, disabledIf +, isPy3k +, ensureNewerSourcesForZipFilesHook }: let @@ -11,6 +14,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"; @@ -88,6 +112,15 @@ in rec { }; } ./setuptools-check-hook.sh) {}; + venvShellHook = disabledIf (!isPy3k) (callPackage ({ }: + makeSetupHook { + name = "venv-shell-hook"; + deps = [ ensureNewerSourcesForZipFilesHook ]; + substitutions = { + inherit pythonInterpreter; + }; + } ./venv-shell-hook.sh) {}); + wheelUnpackHook = callPackage ({ wheel }: makeSetupHook { name = "wheel-unpack-hook.sh"; 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 00000000000..d5abc8d55e5 --- /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 00000000000..ae894fb1bde --- /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 00000000000..c8ed3dee83b --- /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/hooks/venv-shell-hook.sh b/pkgs/development/interpreters/python/hooks/venv-shell-hook.sh new file mode 100644 index 00000000000..3185b1f9fae --- /dev/null +++ b/pkgs/development/interpreters/python/hooks/venv-shell-hook.sh @@ -0,0 +1,26 @@ +venvShellHook() { + echo "Executing venvHook" + runHook preShellHook + + if [ -d "${venvDir}" ]; then + echo "Skipping venv creation, '${venvDir}' already exists" + else + echo "Creating new venv environment in path: '${venvDir}'" + @pythonInterpreter@ -m venv "${venvDir}" + fi + + source "${venvDir}/bin/activate" + + runHook postShellHook + echo "Finished executing venvShellHook" +} + +if [ -z "${dontUseVenvShellHook:-}" ] && [ -z "${shellHook-}" ]; then + echo "Using venvShellHook" + if [ -z "${venvDir-}" ]; then + echo "Error: \`venvDir\` should be set when using \`venvShellHook\`." + exit 1 + else + shellHook=venvShellHook + fi +fi diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index 700894eda6d..020298cc8e9 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/development/interpreters/python/pypy/default.nix b/pkgs/development/interpreters/python/pypy/default.nix index b220bfa0f93..0c4f3eda7b1 100644 --- a/pkgs/development/interpreters/python/pypy/default.nix +++ b/pkgs/development/interpreters/python/pypy/default.nix @@ -1,5 +1,5 @@ { stdenv, substituteAll, fetchurl -, zlib ? null, zlibSupport ? true, bzip2, pkgconfig, libffi +, zlib ? null, zlibSupport ? true, bzip2, pkgconfig, libffi, libunwind, Security , sqlite, openssl_1_0_2, ncurses, python, expat, tcl, tk, tix, xlibsWrapper, libX11 , self, gdbm, db, lzma , python-setup-hook @@ -47,6 +47,8 @@ in with passthru; stdenv.mkDerivation rec { stdenv.cc.libc ] ++ optionals zlibSupport [ zlib + ] ++ optionals stdenv.isDarwin [ + libunwind Security ]; hardeningDisable = optional stdenv.isi686 "pic"; @@ -127,13 +129,17 @@ in with passthru; stdenv.mkDerivation rec { mkdir -p $out/{bin,include,lib,${executable}-c} cp -R {include,lib_pypy,lib-python,${executable}-c} $out/${executable}-c - cp lib${executable}-c.so $out/lib/ + cp lib${executable}-c${stdenv.hostPlatform.extensions.sharedLibrary} $out/lib/ ln -s $out/${executable}-c/${executable}-c $out/bin/${executable} # other packages expect to find stuff according to libPrefix ln -s $out/${executable}/include $out/include/${libPrefix} ln -s $out/${executable}-c/lib-python/${if isPy3k then "3" else pythonVersion} $out/lib/${libPrefix} + ${stdenv.lib.optionalString stdenv.isDarwin '' + install_name_tool -change @rpath/libpypy${optionalString isPy3k "3"}-c.dylib $out/lib/libpypy${optionalString isPy3k "3"}-c.dylib $out/bin/${executable} + ''} + # verify cffi modules $out/bin/${executable} -c ${if isPy3k then "'import tkinter;import sqlite3;import curses;import lzma'" else "'import Tkinter;import sqlite3;import curses'"} diff --git a/pkgs/development/interpreters/python/pypy/tk_tcl_paths.patch b/pkgs/development/interpreters/python/pypy/tk_tcl_paths.patch index 92bbfc557b3..0b78caf7e07 100644 --- a/pkgs/development/interpreters/python/pypy/tk_tcl_paths.patch +++ b/pkgs/development/interpreters/python/pypy/tk_tcl_paths.patch @@ -1,6 +1,13 @@ --- pypy-pypy-84a2f3e6a7f8.org/lib_pypy/_tkinter/tklib_build.py 2017-10-03 11:49:20.000000000 +0100 +++ pypy-pypy-84a2f3e6a7f8/lib_pypy/_tkinter/tklib_build.py 2017-11-21 13:20:51.398607530 +0000 -@@ -24,11 +24,11 @@ +@@ -17,18 +17,14 @@ + incdirs = [] + linklibs = ['tcl85', 'tk85'] + libdirs = [] +-elif sys.platform == 'darwin': +- incdirs = ['/System/Library/Frameworks/Tk.framework/Versions/Current/Headers/'] +- linklibs = ['tcl', 'tk'] +- libdirs = [] else: # On some Linux distributions, the tcl and tk libraries are # stored in /usr/include, so we must check this case also |