about summary refs log tree commit diff
path: root/pkgs/development/interpreters
diff options
context:
space:
mode:
authorFrederik Rietdijk <fridh@fridh.nl>2019-01-03 12:00:44 +0100
committerFrederik Rietdijk <fridh@fridh.nl>2019-01-04 10:45:22 +0100
commitd91b496eac0ff3ccd05d23d5a56199c826802d9b (patch)
tree0bfdeb613ca31489d10a8dd0871c3e440923d5a9 /pkgs/development/interpreters
parent0a2caa41fe0da9e5c36f47994594650f00e1d111 (diff)
downloadnixlib-d91b496eac0ff3ccd05d23d5a56199c826802d9b.tar
nixlib-d91b496eac0ff3ccd05d23d5a56199c826802d9b.tar.gz
nixlib-d91b496eac0ff3ccd05d23d5a56199c826802d9b.tar.bz2
nixlib-d91b496eac0ff3ccd05d23d5a56199c826802d9b.tar.lz
nixlib-d91b496eac0ff3ccd05d23d5a56199c826802d9b.tar.xz
nixlib-d91b496eac0ff3ccd05d23d5a56199c826802d9b.tar.zst
nixlib-d91b496eac0ff3ccd05d23d5a56199c826802d9b.zip
pythonInterpreters.pypy{27,35}_prebuilt: init at 6.0.0
These interpreters are prebuilt by upstream and patched using patchelf.
They are primarily added for testing purposes and development on the
non-prebuilt PyPy interpreters as it can speed up translation
significantly.
Diffstat (limited to 'pkgs/development/interpreters')
-rw-r--r--pkgs/development/interpreters/python/default.nix28
-rw-r--r--pkgs/development/interpreters/python/pypy/prebuilt.nix123
2 files changed, 151 insertions, 0 deletions
diff --git a/pkgs/development/interpreters/python/default.nix b/pkgs/development/interpreters/python/default.nix
index b45dc55390c9..bb5c3b3a97f5 100644
--- a/pkgs/development/interpreters/python/default.nix
+++ b/pkgs/development/interpreters/python/default.nix
@@ -123,4 +123,32 @@ in {
     inherit passthruFun;
   };
 
+  pypy27_prebuilt = callPackage ./pypy/prebuilt.nix {
+    # Not included at top-level
+    self = pythonInterpreters.pypy27_prebuilt;
+    sourceVersion = {
+      major = "6";
+      minor = "0";
+      patch = "0";
+    };
+    sha256 = "0rxgnp3fm18b87ln8bbjr13g2fsf4ka4abkaim6m03y9lwmr9gvc"; # linux64
+    pythonVersion = "2.7";
+    inherit passthruFun;
+    ncurses = ncurses5;
+  };
+
+  pypy35_prebuilt = callPackage ./pypy/prebuilt.nix {
+  # Not included at top-level
+    self = pythonInterpreters.pypy35_prebuilt;
+    sourceVersion = {
+      major = "6";
+      minor = "0";
+      patch = "0";
+    };
+    sha256 = "0j3h08s7wpglghasmym3baycpif5jshvmk9rpav4pwwy5clzmzsc"; # linux64
+    pythonVersion = "3.5";
+    inherit passthruFun;
+    ncurses = ncurses5;
+  };
+
 })
\ No newline at end of file
diff --git a/pkgs/development/interpreters/python/pypy/prebuilt.nix b/pkgs/development/interpreters/python/pypy/prebuilt.nix
new file mode 100644
index 000000000000..cf23a47e5db6
--- /dev/null
+++ b/pkgs/development/interpreters/python/pypy/prebuilt.nix
@@ -0,0 +1,123 @@
+{ stdenv
+, fetchurl
+, python-setup-hook
+, self
+, which
+# Dependencies
+, bzip2
+, zlib
+, openssl
+, expat
+, libffi
+, ncurses
+, tcl
+, tk
+# For the Python package set
+, packageOverrides ? (self: super: {})
+, sourceVersion
+, pythonVersion
+, sha256
+, passthruFun
+}:
+
+# This version of PyPy is primarily added to speed-up translation of
+# our PyPy source build when developing that expression.
+
+with stdenv.lib;
+
+let
+  isPy3k = majorVersion == "3";
+  passthru = passthruFun rec {
+    inherit self sourceVersion pythonVersion packageOverrides;
+    implementation = "pypy";
+    libPrefix = "pypy${pythonVersion}";
+    executable = "pypy${if isPy3k then "3" else ""}";
+    pythonForBuild = self; # Not possible to cross-compile with.
+    sitePackages = "site-packages";
+  };
+  pname = "${passthru.executable}_prebuilt";
+  version = with sourceVersion; "${major}.${minor}.${patch}";
+
+  majorVersion = substring 0 1 pythonVersion;
+
+  setupHook = python-setup-hook sitePackages;
+
+  deps = [
+    bzip2
+    zlib
+    openssl
+    expat
+    libffi
+    ncurses
+    tcl
+    tk
+  ];
+
+in with passthru; stdenv.mkDerivation {
+  inherit pname version;
+
+  src = fetchurl {
+    url= "https://bitbucket.org/pypy/pypy/downloads/pypy${majorVersion}-v${version}-linux64.tar.bz2";
+    inherit sha256;
+  };
+
+  buildInputs = [ which ];
+
+  installPhase = ''
+    mkdir -p $out/lib
+    echo "Moving files to $out"
+    mv -t $out bin include lib-python lib_pypy site-packages
+
+    mv $out/bin/libpypy*-c.so $out/lib/
+
+    rm $out/bin/*.debug
+
+    echo "Patching binaries"
+    interpreter=$(patchelf --print-interpreter $(readlink -f $(which patchelf)))
+    patchelf --set-interpreter $interpreter \
+             --set-rpath $out/lib \
+             $out/bin/pypy*
+
+    pushd $out
+    find {lib,lib_pypy*} -name "*.so" -exec patchelf --replace-needed "libbz2.so.1.0" "libbz2.so.1" {} \;
+    find {lib,lib_pypy*} -name "*.so" -exec patchelf --set-rpath ${stdenv.lib.makeLibraryPath deps} {} \;
+
+    echo "Removing bytecode"
+    find . -name "__pycache__" -type d -depth -exec rm -rf {} \;
+    popd
+  '';
+
+  doInstallCheck = true;
+
+  # Check whether importing of (extension) modules functions
+  installCheckPhase = let
+    modules = [
+      "ssl"
+      "sys"
+      "curses"
+    ] ++ optionals (!isPy3k) [
+      "Tkinter"
+    ] ++ optionals isPy3k [
+      "tkinter"
+    ];
+    imports = concatMapStringsSep "; " (x: "import ${x}") modules;
+  in ''
+    echo "Testing whether we can import modules"
+    $out/bin/${executable} -c '${imports}'
+  '';
+
+  setupHook = python-setup-hook sitePackages;
+
+  donPatchElf = true;
+  dontStrip = true;
+
+  inherit passthru;
+
+  meta = with stdenv.lib; {
+    homepage = http://pypy.org/;
+    description = "Fast, compliant alternative implementation of the Python language (3.5.3)";
+    license = licenses.mit;
+    platforms = [ "x86_64-linux" ];
+  };
+
+}
\ No newline at end of file