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