Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 19.09 103 lines 3.7 kB view raw
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 pname = "python-boot"; 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 # Hack hack hack to stop shit from failing from a missing _scproxy on Darwin. Since 47 # we only use this python for bootstrappy things, it doesn't really matter if it 48 # doesn't have perfect proxy support in urllib :) this just makes it fall back on env 49 # vars instead of attempting to read the proxy configuration automatically, so not a 50 # huge loss even if for whatever reason we did want proxy support. 51 postPatch = '' 52 substituteInPlace Lib/urllib.py --replace "if sys.platform == 'darwin'" "if False" 53 ''; 54 55 DETERMINISTIC_BUILD = 1; 56 57 preConfigure = '' 58 # Purity. 59 for i in /usr /sw /opt /pkg; do 60 substituteInPlace ./setup.py --replace $i /no-such-path 61 done 62 '' + optionalString (stdenv ? cc && stdenv.cc.libc != null) '' 63 for i in Lib/plat-*/regen; do 64 substituteInPlace $i --replace /usr/include/ ${stdenv.cc.libc}/include/ 65 done 66 '' + optionalString stdenv.isDarwin '' 67 substituteInPlace configure --replace '`/usr/bin/arch`' '"i386"' 68 substituteInPlace Lib/multiprocessing/__init__.py \ 69 --replace 'os.popen(comm)' 'os.popen("${coreutils}/bin/nproc")' 70 ''; 71 72 configureFlags = [ "--enable-shared" "--with-threads" "--enable-unicode=ucs4" ] 73 ++ optionals stdenv.isCygwin [ "ac_cv_func_bind_textdomain_codeset=yes" ] 74 ++ optionals stdenv.isDarwin [ "--disable-toolbox-glue" ]; 75 76 postInstall = 77 '' 78 ln -s $out/share/man/man1/{python2.7.1.gz,python.1.gz} 79 80 rm "$out"/lib/python*/plat-*/regen # refers to glibc.dev 81 ''; 82 83 enableParallelBuilding = true; 84 85 passthru.pkgs = builtins.throw "python-boot does not support packages, this package is only intended for bootstrapping." {}; 86 87 meta = { 88 homepage = http://python.org; 89 description = "A high-level dynamically-typed programming language"; 90 longDescription = '' 91 Python is a remarkably powerful dynamic programming language that 92 is used in a wide variety of application domains. Some of its key 93 distinguishing features include: clear, readable syntax; strong 94 introspection capabilities; intuitive object orientation; natural 95 expression of procedural code; full modularity, supporting 96 hierarchical packages; exception-based error handling; and very 97 high level dynamic data types. 98 ''; 99 license = stdenv.lib.licenses.psfl; 100 platforms = stdenv.lib.platforms.all; 101 maintainers = with stdenv.lib.maintainers; [ lnl7 domenkozar ]; 102 }; 103}