1{ stdenv, fetchurl, configd, CF, coreutils }:
2
3with stdenv.lib;
4
5let
6
7 mkPaths = paths: {
8 C_INCLUDE_PATH = makeSearchPathOutput "dev" "include" paths;
9 LIBRARY_PATH = makeLibraryPath paths;
10 };
11
12in
13
14stdenv.mkDerivation rec {
15 name = "python-boot-${version}";
16 version = "2.7.12";
17 libPrefix = "python2.7";
18
19 src = fetchurl {
20 url = "https://www.python.org/ftp/python/2.7.12/Python-${version}.tar.xz";
21 sha256 = "0y7rl603vmwlxm6ilkhc51rx2mfj14ckcz40xxgs0ljnvlhp30yp";
22 };
23
24 inherit (mkPaths buildInputs) C_INCLUDE_PATH LIBRARY_PATH;
25
26 LDFLAGS = optionalString (!stdenv.isDarwin) "-lgcc_s";
27 NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin "-msse2";
28
29 buildInputs = optionals stdenv.isDarwin [ CF configd ];
30
31 patches =
32 [ # Look in C_INCLUDE_PATH and LIBRARY_PATH for stuff.
33 ./search-path.patch
34
35 # Python recompiles a Python if the mtime stored *in* the
36 # pyc/pyo file differs from the mtime of the source file. This
37 # doesn't work in Nix because Nix changes the mtime of files in
38 # the Nix store to 1. So treat that as a special case.
39 ./nix-store-mtime.patch
40
41 # patch python to put zero timestamp into pyc
42 # if DETERMINISTIC_BUILD env var is set
43 ./deterministic-build.patch
44 ];
45
46 DETERMINISTIC_BUILD = 1;
47
48 preConfigure = ''
49 # Purity.
50 for i in /usr /sw /opt /pkg; do
51 substituteInPlace ./setup.py --replace $i /no-such-path
52 done
53 '' + optionalString (stdenv ? cc && stdenv.cc.libc != null) ''
54 for i in Lib/plat-*/regen; do
55 substituteInPlace $i --replace /usr/include/ ${stdenv.cc.libc}/include/
56 done
57 '' + optionalString stdenv.isDarwin ''
58 substituteInPlace configure --replace '`/usr/bin/arch`' '"i386"'
59 substituteInPlace Lib/multiprocessing/__init__.py \
60 --replace 'os.popen(comm)' 'os.popen("${coreutils}/bin/nproc")'
61 '';
62
63 configureFlags = [ "--enable-shared" "--with-threads" "--enable-unicode=ucs4" ]
64 ++ optionals stdenv.isCygwin [ "ac_cv_func_bind_textdomain_codeset=yes" ]
65 ++ optionals stdenv.isDarwin [ "--disable-toolbox-glue" ];
66
67 postInstall =
68 ''
69 ln -s $out/share/man/man1/{python2.7.1.gz,python.1.gz}
70
71 paxmark E $out/bin/python2.7
72
73 rm "$out"/lib/python*/plat-*/regen # refers to glibc.dev
74 '';
75
76 enableParallelBuilding = true;
77
78 passthru.pkgs = builtins.throw "python-boot does not support packages, this package is only intended for bootstrapping." {};
79
80 meta = {
81 homepage = http://python.org;
82 description = "A high-level dynamically-typed programming language";
83 longDescription = ''
84 Python is a remarkably powerful dynamic programming language that
85 is used in a wide variety of application domains. Some of its key
86 distinguishing features include: clear, readable syntax; strong
87 introspection capabilities; intuitive object orientation; natural
88 expression of procedural code; full modularity, supporting
89 hierarchical packages; exception-based error handling; and very
90 high level dynamic data types.
91 '';
92 license = stdenv.lib.licenses.psfl;
93 platforms = stdenv.lib.platforms.all;
94 maintainers = with stdenv.lib.maintainers; [ lnl7 chaoflow domenkozar ];
95 };
96}