at 16.09-beta 4.4 kB view raw
1{ stdenv, fetchurl 2, bzip2 3, gdbm 4, libX11, xproto 5, lzma 6, ncurses 7, openssl 8, readline 9, sqlite 10, tcl, tk 11, zlib 12, callPackage 13, self 14, python35Packages 15 16, CF, configd 17}: 18 19assert readline != null -> ncurses != null; 20 21with stdenv.lib; 22 23let 24 majorVersion = "3.5"; 25 pythonVersion = majorVersion; 26 version = "${majorVersion}.2"; 27 fullVersion = "${version}"; 28 29 buildInputs = filter (p: p != null) [ 30 zlib 31 bzip2 32 lzma 33 gdbm 34 sqlite 35 readline 36 ncurses 37 openssl 38 tcl 39 tk 40 libX11 41 xproto 42 ] ++ optionals stdenv.isDarwin [ CF configd ]; 43in 44stdenv.mkDerivation { 45 name = "python3-${fullVersion}"; 46 pythonVersion = majorVersion; 47 inherit majorVersion version; 48 49 inherit buildInputs; 50 51 src = fetchurl { 52 url = "http://www.python.org/ftp/python/${version}/Python-${fullVersion}.tar.xz"; 53 sha256 = "0h6a5fr7ram2s483lh0pnmc4ncijb8llnpfdxdcl5dxr01hza400"; 54 }; 55 56 NIX_LDFLAGS = optionalString stdenv.isLinux "-lgcc_s"; 57 58 prePatch = optionalString stdenv.isDarwin '' 59 substituteInPlace configure --replace '`/usr/bin/arch`' '"i386"' 60 ''; 61 62 preConfigure = '' 63 for i in /usr /sw /opt /pkg; do # improve purity 64 substituteInPlace ./setup.py --replace $i /no-such-path 65 done 66 ${optionalString stdenv.isDarwin '' 67 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -msse2" 68 export MACOSX_DEPLOYMENT_TARGET=10.6 69 ''} 70 71 configureFlagsArray=( --enable-shared --with-threads 72 CPPFLAGS="${concatStringsSep " " (map (p: "-I${getDev p}/include") buildInputs)}" 73 LDFLAGS="${concatStringsSep " " (map (p: "-L${getLib p}/lib") buildInputs)}" 74 LIBS="${optionalString (!stdenv.isDarwin) "-lcrypt"} ${optionalString (ncurses != null) "-lncurses"}" 75 ) 76 ''; 77 78 setupHook = ./setup-hook.sh; 79 80 postInstall = '' 81 # needed for some packages, especially packages that backport functionality 82 # to 2.x from 3.x 83 for item in $out/lib/python${majorVersion}/test/*; do 84 if [[ "$item" != */test_support.py* ]]; then 85 rm -rf "$item" 86 else 87 echo $item 88 fi 89 done 90 touch $out/lib/python${majorVersion}/test/__init__.py 91 92 ln -s "$out/include/python${majorVersion}m" "$out/include/python${majorVersion}" 93 paxmark E $out/bin/python${majorVersion} 94 ''; 95 96 postFixup = '' 97 # Get rid of retained dependencies on -dev packages, and remove 98 # some $TMPDIR references to improve binary reproducibility. 99 for i in $out/lib//python${majorVersion}/_sysconfigdata.py $out/lib/python${majorVersion}/config-${majorVersion}m/Makefile; do 100 sed -i $i -e "s|-I/nix/store/[^ ']*||g" -e "s|-L/nix/store/[^ ']*||g" -e "s|$TMPDIR|/no-such-path|g" 101 done 102 103 # FIXME: should regenerate this. 104 rm $out/lib/python${majorVersion}/__pycache__/_sysconfigdata.cpython* 105 ''; 106 107 passthru = rec { 108 zlibSupport = zlib != null; 109 sqliteSupport = sqlite != null; 110 dbSupport = false; 111 readlineSupport = readline != null; 112 opensslSupport = openssl != null; 113 tkSupport = (tk != null) && (tcl != null) && (libX11 != null) && (xproto != null); 114 libPrefix = "python${majorVersion}"; 115 executable = "python${majorVersion}m"; 116 buildEnv = callPackage ../../wrapper.nix { python = self; }; 117 withPackages = import ../../with-packages.nix { inherit buildEnv; pythonPackages = python35Packages; }; 118 isPy3 = true; 119 isPy35 = true; 120 is_py3k = true; # deprecated 121 sitePackages = "lib/${libPrefix}/site-packages"; 122 interpreter = "${self}/bin/${executable}"; 123 }; 124 125 enableParallelBuilding = true; 126 127 meta = { 128 homepage = http://python.org; 129 description = "A high-level dynamically-typed programming language"; 130 longDescription = '' 131 Python is a remarkably powerful dynamic programming language that 132 is used in a wide variety of application domains. Some of its key 133 distinguishing features include: clear, readable syntax; strong 134 introspection capabilities; intuitive object orientation; natural 135 expression of procedural code; full modularity, supporting 136 hierarchical packages; exception-based error handling; and very 137 high level dynamic data types. 138 ''; 139 license = licenses.psfl; 140 platforms = with platforms; linux ++ darwin; 141 maintainers = with maintainers; [ chaoflow domenkozar cstrahan ]; 142 }; 143}