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