@@ -1,160 +0,0 @@
1−{ stdenv, fetchurl
2−, bzip2
3−, gdbm
4−, lzma
5−, ncurses
6−, openssl
7−, readline
8−, sqlite
9−, tcl ? null, tk ? null, tix ? null, libX11 ? null, xproto ? null, x11Support ? false
10−, zlib
11−, callPackage
12−, self
13−, CF, configd
14−, python-setup-hook
15−# For the Python package set
16−, pkgs, packageOverrides ? (self: super: {})
17−}:
18−
19−assert x11Support -> tcl != null
20− && tk != null
21− && xproto != null
22− && libX11 != null;
23−
24−with stdenv.lib;
25−
26−let
27− majorVersion = "3.3";
28− minorVersion = "6";
29− minorVersionSuffix = "";
30− pythonVersion = majorVersion;
31− version = "${majorVersion}.${minorVersion}${minorVersionSuffix}";
32− libPrefix = "python${majorVersion}";
33− sitePackages = "lib/${libPrefix}/site-packages";
34−
35− buildInputs = filter (p: p != null) [
36− zlib bzip2 lzma gdbm sqlite readline ncurses openssl ]
37− ++ optionals x11Support [ tcl tk libX11 xproto ]
38− ++ optionals stdenv.isDarwin [ CF configd ];
39−
40−in stdenv.mkDerivation {
41− name = "python3-${version}";
42− pythonVersion = majorVersion;
43− inherit majorVersion version;
44−
45− inherit buildInputs;
46−
47− src = fetchurl {
48− url = "https://www.python.org/ftp/python/${majorVersion}.${minorVersion}/Python-${version}.tar.xz";
49− sha256 = "0gsxpgd5p4mwd01gw501vsyahncyw3h9836ypkr3y32kgazy89jj";
50− };
51−
52− NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isLinux "-lgcc_s";
53−
54− # Determinism: The interpreter is patched to write null timestamps when compiling python files.
55− # This way python doesn't try to update them when we freeze timestamps in nix store.
56− DETERMINISTIC_BUILD=1;
57− # Determinism: We fix the hashes of str, bytes and datetime objects.
58− PYTHONHASHSEED=0;
59−
60− postPatch = ''
61− # Determinism
62− substituteInPlace "Lib/py_compile.py" --replace "source_stats['mtime']" "(1 if 'DETERMINISTIC_BUILD' in os.environ else source_stats['mtime'])"
63−# # We do not patch `Lib/importlib/_bootstrap_external.py` because it does not exist.
64− '' + optionalString (x11Support && (tix != null)) ''
65− substituteInPlace "Lib/tkinter/tix.py" --replace "os.environ.get('TIX_LIBRARY')" "os.environ.get('TIX_LIBRARY') or '${tix}/lib'"
66− '';
67−
68− preConfigure = ''
69− for i in /usr /sw /opt /pkg; do # improve purity
70− substituteInPlace ./setup.py --replace $i /no-such-path
71− done
72− ${optionalString stdenv.isDarwin ''export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -msse2"''}
73−
74− configureFlagsArray=( --enable-shared --with-threads
75− CPPFLAGS="${concatStringsSep " " (map (p: "-I${getDev p}/include") buildInputs)}"
76− LDFLAGS="${concatStringsSep " " (map (p: "-L${getLib p}/lib") buildInputs)}"
77− LIBS="${optionalString (!stdenv.isDarwin) "-lcrypt"} ${optionalString (ncurses != null) "-lncurses"}"
78− )
79− '';
80−
81− setupHook = python-setup-hook sitePackages;
82−
83− postInstall = ''
84− # needed for some packages, especially packages that backport functionality
85− # to 2.x from 3.x
86− for item in $out/lib/python${majorVersion}/test/*; do
87− if [[ "$item" != */test_support.py* ]]; then
88− rm -rf "$item"
89− else
90− echo $item
91− fi
92− done
93− touch $out/lib/python${majorVersion}/test/__init__.py
94−
95− ln -s "$out/include/python${majorVersion}m" "$out/include/python${majorVersion}"
96− paxmark E $out/bin/python${majorVersion}
97−
98− # Python on Nix is not manylinux1 compatible. https://github.com/NixOS/nixpkgs/issues/18484
99− echo "manylinux1_compatible=False" >> $out/lib/${libPrefix}/_manylinux.py
100−
101− # Determinism: Windows installers were not deterministic.
102− # We're also not interested in building Windows installers.
103− find "$out" -name 'wininst*.exe' | xargs -r rm -f
104−
105− # Use Python3 as default python
106− ln -s "$out/bin/idle3" "$out/bin/idle"
107− ln -s "$out/bin/pip3" "$out/bin/pip"
108− ln -s "$out/bin/pydoc3" "$out/bin/pydoc"
109− ln -s "$out/bin/python3" "$out/bin/python"
110− ln -s "$out/bin/python3-config" "$out/bin/python-config"
111− ln -s "$out/lib/pkgconfig/python3.pc" "$out/lib/pkgconfig/python.pc"
112−
113− # Get rid of retained dependencies on -dev packages, and remove
114− # some $TMPDIR references to improve binary reproducibility.
115− # Note that the .pyc file of _sysconfigdata.py should be regenerated!
116− for i in $out/lib/python${majorVersion}/_sysconfigdata.py $out/lib/python${majorVersion}/config-${majorVersion}m/Makefile; do
117− sed -i $i -e "s|-I/nix/store/[^ ']*||g" -e "s|-L/nix/store/[^ ']*||g" -e "s|$TMPDIR|/no-such-path|g"
118− done
119−
120− # Determinism: rebuild all bytecode
121− # We exclude lib2to3 because that's Python 2 code which fails
122− # We rebuild three times, once for each optimization level
123− find $out -name "*.py" | $out/bin/python -m compileall -q -f -x "lib2to3" -i -
124− find $out -name "*.py" | $out/bin/python -O -m compileall -q -f -x "lib2to3" -i -
125− find $out -name "*.py" | $out/bin/python -OO -m compileall -q -f -x "lib2to3" -i -
126− '';
127−
128− passthru = let
129− pythonPackages = callPackage ../../../../../top-level/python-packages.nix {python=self; overrides=packageOverrides;};
130− in rec {
131− inherit libPrefix sitePackages x11Support;
132− executable = "${libPrefix}m";
133− buildEnv = callPackage ../../wrapper.nix { python = self; };
134− withPackages = import ../../with-packages.nix { inherit buildEnv pythonPackages;};
135− pkgs = pythonPackages;
136− isPy3 = true;
137− isPy33 = true;
138− is_py3k = true; # deprecated
139− interpreter = "${self}/bin/${executable}";
140− };
141−
142− enableParallelBuilding = true;
143−
144− meta = {
145− homepage = http://python.org;
146− description = "A high-level dynamically-typed programming language";
147− longDescription = ''
148− Python is a remarkably powerful dynamic programming language that
149− is used in a wide variety of application domains. Some of its key
150− distinguishing features include: clear, readable syntax; strong
151− introspection capabilities; intuitive object orientation; natural
152− expression of procedural code; full modularity, supporting
153− hierarchical packages; exception-based error handling; and very
154− high level dynamic data types.
155− '';
156− license = stdenv.lib.licenses.psfl;
157− platforms = with stdenv.lib.platforms; linux ++ darwin;
158− maintainers = with stdenv.lib.maintainers; [ chaoflow cstrahan ];
159− };
160−}