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