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