Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

python: make 2.6 and 2.7 expr similar, introduce includeModules

When includeModules is true, python is built with all optional modules
as part of derivation.

+54 -62
+29 -24
pkgs/development/interpreters/python/2.6/default.nix
··· 1 - { stdenv, fetchurl, zlib ? null, zlibSupport ? true, bzip2 2 - , sqlite, tcl, tk, x11, openssl, readline, db, ncurses, gdbm 3 - }: 1 + { stdenv, fetchurl, zlib ? null, zlibSupport ? true, bzip2, includeModules ? false 2 + , sqlite, tcl, tk, x11, openssl, readline, db, ncurses, gdbm}: 4 3 5 4 assert zlibSupport -> zlib != null; 6 5 7 6 with stdenv.lib; 8 7 9 8 let 10 - 11 9 majorVersion = "2.6"; 12 10 version = "${majorVersion}.9"; 13 11 ··· 27 25 # the Nix store to 1. So treat that as a special case. 28 26 ./nix-store-mtime.patch 29 27 ]; 28 + 29 + preConfigure = '' 30 + # Purity. 31 + for i in /usr /sw /opt /pkg; do 32 + substituteInPlace ./setup.py --replace $i /no-such-path 33 + done 34 + '' + optionalString (stdenv ? gcc && stdenv.gcc.libc != null) '' 35 + for i in Lib/plat-*/regen; do 36 + substituteInPlace $i --replace /usr/include/ ${stdenv.gcc.libc}/include/ 37 + done 38 + '' + optionalString stdenv.isCygwin '' 39 + # On Cygwin, `make install' tries to read this Makefile. 40 + mkdir -p $out/lib/python${majorVersion}/config 41 + touch $out/lib/python${majorVersion}/config/Makefile 42 + mkdir -p $out/include/python${majorVersion} 43 + touch $out/include/python${majorVersion}/pyconfig.h 44 + ''; 30 45 31 46 buildInputs = 32 47 optional (stdenv ? gcc && stdenv.gcc.libc != null) stdenv.gcc.libc ++ 33 - [ bzip2 openssl ] 48 + [ bzip2 openssl ]++ optionals includeModules [ db openssl ncurses gdbm readline x11 tcl tk sqlite ] 34 49 ++ optional zlibSupport zlib; 35 50 36 51 37 52 # Build the basic Python interpreter without modules that have 38 53 # external dependencies. 39 54 python = stdenv.mkDerivation { 40 - name = "python-${version}"; 55 + name = "python${if includeModules then "" else "-minimal"}-${version}"; 41 56 42 - inherit majorVersion version src patches buildInputs; 57 + inherit majorVersion version src patches buildInputs preConfigure; 43 58 44 59 C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs); 45 60 LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") buildInputs); 46 61 47 62 configureFlags = "--enable-shared --with-threads --enable-unicode"; 48 63 49 - preConfigure = 50 - '' 51 - # Purity. 52 - for i in /usr /sw /opt /pkg; do 53 - substituteInPlace ./setup.py --replace $i /no-such-path 54 - done 55 - '' + optionalString (stdenv ? gcc && stdenv.gcc.libc != null) '' 56 - for i in Lib/plat-*/regen; do 57 - substituteInPlace $i --replace /usr/include/ ${stdenv.gcc.libc}/include/ 58 - done 59 - ''; 60 - 61 64 NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin "-msse2"; 62 65 63 66 setupHook = ./setup-hook.sh; ··· 69 72 ln -s $out/lib/python${majorVersion}/pdb.py $out/bin/pdb${majorVersion} 70 73 mv $out/share/man/man1/{python.1,python2.6.1} 71 74 ln -s $out/share/man/man1/{python2.6.1,python.1} 75 + 76 + paxmark E $out/bin/python${majorVersion} 77 + 78 + ${ optionalString includeModules "$out/bin/python ./setup.py build_ext"} 72 79 ''; 73 80 74 81 passthru = rec { ··· 96 103 ''; 97 104 license = stdenv.lib.licenses.psfl; 98 105 platforms = stdenv.lib.platforms.all; 99 - maintainers = with stdenv.lib.maintainers; [ simons chaoflow ]; 106 + maintainers = with stdenv.lib.maintainers; [ simons chaoflow iElectric ]; 100 107 }; 101 108 }; 102 109 ··· 108 115 , internalName ? "_" + moduleName 109 116 , deps 110 117 }: 111 - stdenv.mkDerivation rec { 118 + if (includeModules) then null else stdenv.mkDerivation rec { 112 119 name = "python-${moduleName}-${python.version}"; 113 120 114 - inherit src patches; 121 + inherit src patches preConfigure; 115 122 116 123 buildInputs = [ python ] ++ deps; 117 124 118 125 C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs); 119 126 LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") buildInputs); 120 - 121 - configurePhase = "true"; 122 127 123 128 buildPhase = 124 129 ''
+25 -38
pkgs/development/interpreters/python/2.7/default.nix
··· 1 - { stdenv, fetchurl, zlib ? null, zlibSupport ? true, bzip2 1 + { stdenv, fetchurl, zlib ? null, zlibSupport ? true, bzip2, includeModules ? false 2 2 , sqlite, tcl, tk, x11, openssl, readline, db, ncurses, gdbm, libX11 }: 3 3 4 4 assert zlibSupport -> zlib != null; ··· 6 6 with stdenv.lib; 7 7 8 8 let 9 - 10 9 majorVersion = "2.7"; 11 10 version = "${majorVersion}.8"; 12 11 ··· 29 28 # if DETERMINISTIC_BUILD env var is set 30 29 ./deterministic-build.patch 31 30 ]; 32 - 33 - postPatch = stdenv.lib.optionalString (stdenv.gcc.libc != null) '' 34 - substituteInPlace ./Lib/plat-generic/regen \ 35 - --replace /usr/include/netinet/in.h \ 36 - ${stdenv.gcc.libc}/include/netinet/in.h 37 - ''; 38 - 39 - buildInputs = 40 - optional (stdenv ? gcc && stdenv.gcc.libc != null) stdenv.gcc.libc ++ 41 - [ bzip2 openssl ] 42 - ++ optional zlibSupport zlib; 43 - 44 - ensurePurity = 45 - '' 31 + 32 + preConfigure = '' 46 33 # Purity. 47 34 for i in /usr /sw /opt /pkg; do 48 35 substituteInPlace ./setup.py --replace $i /no-such-path 49 36 done 37 + '' + optionalString (stdenv ? gcc && stdenv.gcc.libc != null) '' 38 + for i in Lib/plat-*/regen; do 39 + substituteInPlace $i --replace /usr/include/ ${stdenv.gcc.libc}/include/ 40 + done 41 + '' + optionalString stdenv.isCygwin '' 42 + # On Cygwin, `make install' tries to read this Makefile. 43 + mkdir -p $out/lib/python${majorVersion}/config 44 + touch $out/lib/python${majorVersion}/config/Makefile 45 + mkdir -p $out/include/python${majorVersion} 46 + touch $out/include/python${majorVersion}/pyconfig.h 50 47 ''; 51 48 49 + buildInputs = 50 + optional (stdenv ? gcc && stdenv.gcc.libc != null) stdenv.gcc.libc ++ 51 + [ bzip2 openssl ] ++ optionals includeModules [ db openssl ncurses gdbm libX11 readline x11 tcl tk sqlite ] 52 + ++ optional zlibSupport zlib; 53 + 52 54 # Build the basic Python interpreter without modules that have 53 55 # external dependencies. 54 56 python = stdenv.mkDerivation { 55 57 name = "python-${version}"; 56 58 57 - inherit majorVersion version src patches postPatch buildInputs; 59 + inherit majorVersion version src patches buildInputs preConfigure; 58 60 59 61 LDFLAGS = stdenv.lib.optionalString (!stdenv.isDarwin) "-lgcc_s"; 60 62 C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs); ··· 62 64 63 65 configureFlags = "--enable-shared --with-threads --enable-unicode"; 64 66 65 - preConfigure = "${ensurePurity}" + optionalString stdenv.isCygwin 66 - '' 67 - # On Cygwin, `make install' tries to read this Makefile. 68 - mkdir -p $out/lib/python${majorVersion}/config 69 - touch $out/lib/python${majorVersion}/config/Makefile 70 - mkdir -p $out/include/python${majorVersion} 71 - touch $out/include/python${majorVersion}/pyconfig.h 72 - ''; 73 - 74 67 NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin "-msse2"; 75 68 76 69 setupHook = ./setup-hook.sh; ··· 83 76 ln -s $out/share/man/man1/{python2.7.1.gz,python.1.gz} 84 77 85 78 paxmark E $out/bin/python${majorVersion} 79 + 80 + ${ optionalString includeModules "$out/bin/python ./setup.py build_ext"} 86 81 ''; 87 82 88 83 passthru = rec { ··· 110 105 ''; 111 106 license = stdenv.lib.licenses.psfl; 112 107 platforms = stdenv.lib.platforms.all; 113 - maintainers = with stdenv.lib.maintainers; [ simons chaoflow ]; 108 + maintainers = with stdenv.lib.maintainers; [ simons chaoflow iElectric ]; 114 109 }; 115 110 }; 116 111 ··· 122 117 , internalName ? "_" + moduleName 123 118 , deps 124 119 }: 125 - stdenv.mkDerivation rec { 120 + if (includeModules) then null else stdenv.mkDerivation rec { 126 121 name = "python-${moduleName}-${python.version}"; 127 122 128 - inherit src patches postPatch; 123 + inherit src patches preConfigure; 129 124 130 125 buildInputs = [ python ] ++ deps; 131 126 132 127 C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs); 133 128 LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") buildInputs); 134 129 135 - configurePhase = "${ensurePurity}"; 136 - 137 - buildPhase = 138 - '' 139 - # Fake the build environment that setup.py expects. 140 - ln -s ${python}/include/python*/pyconfig.h . 141 - ln -s ${python}/lib/python*/config/Setup Modules/ 142 - ln -s ${python}/lib/python*/config/Setup.local Modules/ 143 - 130 + buildPhase = '' 144 131 substituteInPlace setup.py --replace 'self.extensions = extensions' \ 145 132 'self.extensions = [ext for ext in self.extensions if ext.name in ["${internalName}"]]' 146 133