git.iko.soy/typeable/nixpkgs
on master help sign in
pypy3: init at 6.0.0

Signed-off-by: Anders Kaseorg <andersk@mit.edu>

commit85379a29ec289dff040e1f8e3f4cec9374af70ef authorAnders Kaseorg <andersk@mit.edu> dateTue 15 May 2018, 01:46 (9 years ago) parent3504cfe
6 files changed+177−6
doc/languages-frameworks/python.section.md+6−4 maintainers/maintainer-list.nix+5 pkgs/development/interpreters/python/pypy/3/default.nix+138 pkgs/development/interpreters/python/pypy/3/tk_tcl_paths.patch+17 pkgs/top-level/all-packages.nix+10−1 pkgs/top-level/python-packages.nix+1−1
doc/languages-frameworks/python.section.md+6−4
@@ -484,10 +484,12 @@ and in this case the `python35` interpreter is automatically used.
484484### Interpreters
485485
486486Versions 2.7, 3.5, 3.6 and 3.7 of the CPython interpreter are available as
487−respectively `python27`, `python35`, `python36`, and `python37`. The PyPy
488−interpreter is available as `pypy`. The aliases `python2` and `python3`
489−correspond to respectively `python27` and `python37`. The default interpreter,
490−`python`, maps to `python2`. The Nix expressions for the interpreters can be
487+respectively `python27`, `python35`, `python36` and `python37`. The aliases
488+`python2` and `python3` correspond to respectively `python27` and
489+`python37`. The default interpreter, `python`, maps to `python2`. The PyPy
490+interpreters compatible with Python 2.7 and 3 are available as `pypy27` and
491+`pypy3`, with aliases `pypy2` mapping to `pypy27` and `pypy` mapping to
492+`pypy2`. The Nix expressions for the interpreters can be
491493found in `pkgs/development/interpreters/python`.
492494
493495All packages depending on any Python interpreter get appended
maintainers/maintainer-list.nix+5
@@ -256,6 +256,11 @@
256256 github = "AndrewMorsillo";
257257 name = "Andrew Morsillo";
258258 };
259+ andersk = {
260+ email = "andersk@mit.edu";
261+ github = "andersk";
262+ name = "Anders Kaseorg";
263+ };
259264 AndersonTorres = {
260265 email = "torres.anderson.85@protonmail.com";
261266 github = "AndersonTorres";
pkgs/development/interpreters/python/pypy/3/default.nixnew file+138
@@ -0,0 +1,138 @@
1+{ stdenv, substituteAll, fetchurl
2+, zlib ? null, zlibSupport ? true, bzip2, pkgconfig, libffi
3+, sqlite, openssl, ncurses, python, expat, tcl, tk, tix, xlibsWrapper, libX11
4+, makeWrapper, callPackage, self, gdbm, db, lzma
5+, python-setup-hook
6+# For the Python package set
7+, packageOverrides ? (self: super: {})
8+}:
9+
10+assert zlibSupport -> zlib != null;
11+
12+let
13+ version = "6.0.0";
14+ pythonVersion = "3.5";
15+ libPrefix = "pypy${pythonVersion}";
16+ sitePackages = "site-packages";
17+
18+ pythonForPypy = python.withPackages (ppkgs: [ ppkgs.pycparser ]);
19+
20+in stdenv.mkDerivation rec {
21+ name = "pypy3-${version}";
22+ inherit version pythonVersion;
23+
24+ src = fetchurl {
25+ url = "https://bitbucket.org/pypy/pypy/get/release-pypy${pythonVersion}-v${version}.tar.bz2";
26+ sha256 = "0lwq8nn0r5yj01bwmkk5p7xvvrp4s550l8184mkmn74d3gphrlwg";
27+ };
28+
29+ nativeBuildInputs = [ pkgconfig makeWrapper ];
30+ buildInputs = [
31+ bzip2 openssl pythonForPypy libffi ncurses expat sqlite tk tcl xlibsWrapper libX11 gdbm db lzma
32+ ] ++ stdenv.lib.optional (stdenv ? cc && stdenv.cc.libc != null) stdenv.cc.libc
33+ ++ stdenv.lib.optional zlibSupport zlib;
34+
35+ hardeningDisable = stdenv.lib.optional stdenv.isi686 "pic";
36+
37+ C_INCLUDE_PATH = stdenv.lib.makeSearchPathOutput "dev" "include" buildInputs;
38+ LIBRARY_PATH = stdenv.lib.makeLibraryPath buildInputs;
39+ LD_LIBRARY_PATH = stdenv.lib.makeLibraryPath (stdenv.lib.filter (x : x.outPath != stdenv.cc.libc.outPath or "") buildInputs);
40+
41+ patches = [
42+ (substituteAll {
43+ src = ./tk_tcl_paths.patch;
44+ inherit tk tcl;
45+ tk_dev = tk.dev;
46+ tcl_dev = tcl;
47+ tk_libprefix = tk.libPrefix;
48+ tcl_libprefix = tcl.libPrefix;
49+ })
50+ ];
51+
52+ postPatch = ''
53+ substituteInPlace "lib-python/3/tkinter/tix.py" --replace "os.environ.get('TIX_LIBRARY')" "os.environ.get('TIX_LIBRARY') or '${tix}/lib'"
54+
55+ # hint pypy to find nix ncurses
56+ substituteInPlace pypy/module/_minimal_curses/fficurses.py \
57+ --replace "/usr/include/ncurses/curses.h" "${ncurses.dev}/include/curses.h" \
58+ --replace "ncurses/curses.h" "${ncurses.dev}/include/curses.h" \
59+ --replace "ncurses/term.h" "${ncurses.dev}/include/term.h" \
60+ --replace "libraries=['curses']" "libraries=['ncurses']"
61+
62+ sed -i "s@libraries=\['sqlite3'\]\$@libraries=['sqlite3'], include_dirs=['${sqlite.dev}/include'], library_dirs=['${sqlite.out}/lib']@" lib_pypy/_sqlite3_build.py
63+ '';
64+
65+ buildPhase = ''
66+ ${pythonForPypy.interpreter} rpython/bin/rpython \
67+ --make-jobs="$NIX_BUILD_CORES" \
68+ -Ojit \
69+ --batch pypy/goal/targetpypystandalone.py
70+ '';
71+
72+ setupHook = python-setup-hook sitePackages;
73+
74+ doCheck = true;
75+ checkPhase = ''
76+ export TERMINFO="${ncurses.out}/share/terminfo/";
77+ export TERM="xterm";
78+ export HOME="$TMPDIR";
79+ # disable asyncio due to https://github.com/NixOS/nix/issues/1238
80+ # disable os due to https://github.com/NixOS/nixpkgs/issues/10496
81+ # disable pathlib due to https://bitbucket.org/pypy/pypy/pull-requests/594
82+ # disable shutils because it assumes gid 0 exists
83+ # disable socket because it has two actual network tests that fail
84+ # disable tarfile because it assumes gid 0 exists
85+ ${pythonForPypy.interpreter} ./pypy/test_all.py --pypy=./pypy3-c -k 'not ( test_asyncio or test_os or test_pathlib or test_shutil or test_socket or test_tarfile )' lib-python
86+ '';
87+
88+ installPhase = ''
89+ mkdir -p $out/{bin,include,lib,pypy3-c}
90+
91+ cp -R {include,lib_pypy,lib-python,pypy3-c} $out/pypy3-c
92+ cp libpypy3-c.so $out/lib/
93+ ln -s $out/pypy3-c/pypy3-c $out/bin/pypy3
94+
95+ # other packages expect to find stuff according to libPrefix
96+ ln -s $out/pypy3-c/include $out/include/${libPrefix}
97+ ln -s $out/pypy3-c/lib-python/3 $out/lib/${libPrefix}
98+
99+ # We must wrap the original, not the symlink.
100+ # PyPy uses argv[0] to find its standard library, and while it knows
101+ # how to follow symlinks, it doesn't know about wrappers. So, it
102+ # will think the wrapper is the original. As long as the wrapper has
103+ # the same path as the original, this is OK.
104+ wrapProgram "$out/pypy3-c/pypy3-c" \
105+ --set LD_LIBRARY_PATH "${LD_LIBRARY_PATH}:$out/lib" \
106+ --set LIBRARY_PATH "${LIBRARY_PATH}:$out/lib"
107+
108+ # verify cffi modules
109+ $out/bin/pypy3 -c "import tkinter;import sqlite3;import curses;import lzma"
110+
111+ # Python on Nix is not manylinux1 compatible. https://github.com/NixOS/nixpkgs/issues/18484
112+ echo "manylinux1_compatible=False" >> $out/lib/${libPrefix}/_manylinux.py
113+ '';
114+
115+ passthru = let
116+ pythonPackages = callPackage ../../../../../top-level/python-packages.nix {python=self; overrides=packageOverrides;};
117+ in rec {
118+ inherit zlibSupport libPrefix sitePackages;
119+ executable = "pypy3";
120+ isPypy = true;
121+ isPy3 = true;
122+ isPy35 = true;
123+ buildEnv = callPackage ../../wrapper.nix { python = self; inherit (pythonPackages) requiredPythonModules; };
124+ interpreter = "${self}/bin/${executable}";
125+ withPackages = import ../../with-packages.nix { inherit buildEnv pythonPackages;};
126+ pkgs = pythonPackages;
127+ };
128+
129+ enableParallelBuilding = true; # almost no parallelization without STM
130+
131+ meta = with stdenv.lib; {
132+ homepage = http://pypy.org/;
133+ description = "Fast, compliant alternative implementation of the Python language (3.5.3)";
134+ license = licenses.mit;
135+ platforms = [ "i686-linux" "x86_64-linux" ];
136+ maintainers = with maintainers; [ andersk ];
137+ };
138+}
pkgs/development/interpreters/python/pypy/3/tk_tcl_paths.patchnew file+17
@@ -0,0 +1,17 @@
1+--- pypy-pypy-84a2f3e6a7f8.org/lib_pypy/_tkinter/tklib_build.py 2017-10-03 11:49:20.000000000 +0100
2++++ pypy-pypy-84a2f3e6a7f8/lib_pypy/_tkinter/tklib_build.py 2017-11-21 13:20:51.398607530 +0000
3+@@ -24,11 +24,11 @@
4+ else:
5+ # On some Linux distributions, the tcl and tk libraries are
6+ # stored in /usr/include, so we must check this case also
7+- libdirs = []
8++ libdirs = ["@tcl@/lib", "@tk@/lib"]
9+ found = False
10+ for _ver in ['', '8.6', '8.5']:
11+- incdirs = ['/usr/include/tcl' + _ver]
12+- linklibs = ['tcl' + _ver, 'tk' + _ver]
13++ incdirs = ['@tcl_dev@/include', '@tk_dev@/include']
14++ linklibs = ['@tcl_libprefix@', '@tk_libprefix@']
15+ if os.path.isdir(incdirs[0]):
16+ found = True
17+ break
pkgs/top-level/all-packages.nix+10−1
@@ -7950,7 +7950,8 @@ in
79507950 python = python2;
79517951 python2 = python27;
79527952 python3 = python37;
7953− pypy = pypy27;
7953+ pypy = pypy2;
7954+ pypy2 = pypy27;
79547955
79557956 # Python interpreter that is build with all modules, including tkinter.
79567957 # These are for compatibility and should not be used inside Nixpkgs.
@@ -7989,6 +7990,11 @@ in
79897990 python = python27.override{x11Support=true;};
79907991 db = db.override { dbmSupport = true; };
79917992 };
7993+ pypy3 = callPackage ../development/interpreters/python/pypy/3 {
7994+ self = pypy3;
7995+ python = python27;
7996+ db = db.override { dbmSupport = true; };
7997+ };
79927998
79937999 # Python package sets.
79948000 python27Packages = lib.hiPrioSet (recurseIntoAttrs python27.pkgs);
@@ -7996,6 +8002,9 @@ in
79968002 python36Packages = python36.pkgs;
79978003 python37Packages = recurseIntoAttrs python37.pkgs;
79988004 pypyPackages = pypy.pkgs;
8005+ pypy2Packages = pypy2.pkgs;
8006+ pypy27Packages = pypy27.pkgs;
8007+ pypy3Packages = pypy3.pkgs;
79998008
80008009 update-python-libraries = callPackage ../development/interpreters/python/update-python-libraries { };
80018010
pkgs/top-level/python-packages.nix+1−1
@@ -26,7 +26,7 @@ let
2626 isPy35 = python.pythonVersion == "3.5";
2727 isPy36 = python.pythonVersion == "3.6";
2828 isPy37 = python.pythonVersion == "3.7";
29− isPyPy = python.executable == "pypy";
29+ isPyPy = strings.substring 0 4 python.executable == "pypy";
3030 isPy3k = strings.substring 0 1 python.pythonVersion == "3";
3131
3232 callPackage = pkgs.newScope self;