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.
This commit is contained in:
parent
bbf3a18746
commit
8de9ac5bd4
|
@ -1,13 +1,11 @@
|
||||||
{ stdenv, fetchurl, zlib ? null, zlibSupport ? true, bzip2
|
{ stdenv, fetchurl, zlib ? null, zlibSupport ? true, bzip2, includeModules ? false
|
||||||
, sqlite, tcl, tk, x11, openssl, readline, db, ncurses, gdbm
|
, sqlite, tcl, tk, x11, openssl, readline, db, ncurses, gdbm}:
|
||||||
}:
|
|
||||||
|
|
||||||
assert zlibSupport -> zlib != null;
|
assert zlibSupport -> zlib != null;
|
||||||
|
|
||||||
with stdenv.lib;
|
with stdenv.lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
majorVersion = "2.6";
|
majorVersion = "2.6";
|
||||||
version = "${majorVersion}.9";
|
version = "${majorVersion}.9";
|
||||||
|
|
||||||
|
@ -28,36 +26,41 @@ let
|
||||||
./nix-store-mtime.patch
|
./nix-store-mtime.patch
|
||||||
];
|
];
|
||||||
|
|
||||||
|
preConfigure = ''
|
||||||
|
# Purity.
|
||||||
|
for i in /usr /sw /opt /pkg; do
|
||||||
|
substituteInPlace ./setup.py --replace $i /no-such-path
|
||||||
|
done
|
||||||
|
'' + optionalString (stdenv ? gcc && stdenv.gcc.libc != null) ''
|
||||||
|
for i in Lib/plat-*/regen; do
|
||||||
|
substituteInPlace $i --replace /usr/include/ ${stdenv.gcc.libc}/include/
|
||||||
|
done
|
||||||
|
'' + optionalString stdenv.isCygwin ''
|
||||||
|
# On Cygwin, `make install' tries to read this Makefile.
|
||||||
|
mkdir -p $out/lib/python${majorVersion}/config
|
||||||
|
touch $out/lib/python${majorVersion}/config/Makefile
|
||||||
|
mkdir -p $out/include/python${majorVersion}
|
||||||
|
touch $out/include/python${majorVersion}/pyconfig.h
|
||||||
|
'';
|
||||||
|
|
||||||
buildInputs =
|
buildInputs =
|
||||||
optional (stdenv ? gcc && stdenv.gcc.libc != null) stdenv.gcc.libc ++
|
optional (stdenv ? gcc && stdenv.gcc.libc != null) stdenv.gcc.libc ++
|
||||||
[ bzip2 openssl ]
|
[ bzip2 openssl ]++ optionals includeModules [ db openssl ncurses gdbm readline x11 tcl tk sqlite ]
|
||||||
++ optional zlibSupport zlib;
|
++ optional zlibSupport zlib;
|
||||||
|
|
||||||
|
|
||||||
# Build the basic Python interpreter without modules that have
|
# Build the basic Python interpreter without modules that have
|
||||||
# external dependencies.
|
# external dependencies.
|
||||||
python = stdenv.mkDerivation {
|
python = stdenv.mkDerivation {
|
||||||
name = "python-${version}";
|
name = "python${if includeModules then "" else "-minimal"}-${version}";
|
||||||
|
|
||||||
inherit majorVersion version src patches buildInputs;
|
inherit majorVersion version src patches buildInputs preConfigure;
|
||||||
|
|
||||||
C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs);
|
C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs);
|
||||||
LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") buildInputs);
|
LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") buildInputs);
|
||||||
|
|
||||||
configureFlags = "--enable-shared --with-threads --enable-unicode";
|
configureFlags = "--enable-shared --with-threads --enable-unicode";
|
||||||
|
|
||||||
preConfigure =
|
|
||||||
''
|
|
||||||
# Purity.
|
|
||||||
for i in /usr /sw /opt /pkg; do
|
|
||||||
substituteInPlace ./setup.py --replace $i /no-such-path
|
|
||||||
done
|
|
||||||
'' + optionalString (stdenv ? gcc && stdenv.gcc.libc != null) ''
|
|
||||||
for i in Lib/plat-*/regen; do
|
|
||||||
substituteInPlace $i --replace /usr/include/ ${stdenv.gcc.libc}/include/
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
|
|
||||||
NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin "-msse2";
|
NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin "-msse2";
|
||||||
|
|
||||||
setupHook = ./setup-hook.sh;
|
setupHook = ./setup-hook.sh;
|
||||||
|
@ -69,6 +72,10 @@ let
|
||||||
ln -s $out/lib/python${majorVersion}/pdb.py $out/bin/pdb${majorVersion}
|
ln -s $out/lib/python${majorVersion}/pdb.py $out/bin/pdb${majorVersion}
|
||||||
mv $out/share/man/man1/{python.1,python2.6.1}
|
mv $out/share/man/man1/{python.1,python2.6.1}
|
||||||
ln -s $out/share/man/man1/{python2.6.1,python.1}
|
ln -s $out/share/man/man1/{python2.6.1,python.1}
|
||||||
|
|
||||||
|
paxmark E $out/bin/python${majorVersion}
|
||||||
|
|
||||||
|
${ optionalString includeModules "$out/bin/python ./setup.py build_ext"}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru = rec {
|
passthru = rec {
|
||||||
|
@ -96,7 +103,7 @@ let
|
||||||
'';
|
'';
|
||||||
license = stdenv.lib.licenses.psfl;
|
license = stdenv.lib.licenses.psfl;
|
||||||
platforms = stdenv.lib.platforms.all;
|
platforms = stdenv.lib.platforms.all;
|
||||||
maintainers = with stdenv.lib.maintainers; [ simons chaoflow ];
|
maintainers = with stdenv.lib.maintainers; [ simons chaoflow iElectric ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -108,18 +115,16 @@ let
|
||||||
, internalName ? "_" + moduleName
|
, internalName ? "_" + moduleName
|
||||||
, deps
|
, deps
|
||||||
}:
|
}:
|
||||||
stdenv.mkDerivation rec {
|
if (includeModules) then null else stdenv.mkDerivation rec {
|
||||||
name = "python-${moduleName}-${python.version}";
|
name = "python-${moduleName}-${python.version}";
|
||||||
|
|
||||||
inherit src patches;
|
inherit src patches preConfigure;
|
||||||
|
|
||||||
buildInputs = [ python ] ++ deps;
|
buildInputs = [ python ] ++ deps;
|
||||||
|
|
||||||
C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs);
|
C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs);
|
||||||
LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") buildInputs);
|
LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") buildInputs);
|
||||||
|
|
||||||
configurePhase = "true";
|
|
||||||
|
|
||||||
buildPhase =
|
buildPhase =
|
||||||
''
|
''
|
||||||
# Fake the build environment that setup.py expects.
|
# Fake the build environment that setup.py expects.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ stdenv, fetchurl, zlib ? null, zlibSupport ? true, bzip2
|
{ stdenv, fetchurl, zlib ? null, zlibSupport ? true, bzip2, includeModules ? false
|
||||||
, sqlite, tcl, tk, x11, openssl, readline, db, ncurses, gdbm, libX11 }:
|
, sqlite, tcl, tk, x11, openssl, readline, db, ncurses, gdbm, libX11 }:
|
||||||
|
|
||||||
assert zlibSupport -> zlib != null;
|
assert zlibSupport -> zlib != null;
|
||||||
|
@ -6,7 +6,6 @@ assert zlibSupport -> zlib != null;
|
||||||
with stdenv.lib;
|
with stdenv.lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
majorVersion = "2.7";
|
majorVersion = "2.7";
|
||||||
version = "${majorVersion}.8";
|
version = "${majorVersion}.8";
|
||||||
|
|
||||||
|
@ -30,31 +29,34 @@ let
|
||||||
./deterministic-build.patch
|
./deterministic-build.patch
|
||||||
];
|
];
|
||||||
|
|
||||||
postPatch = stdenv.lib.optionalString (stdenv.gcc.libc != null) ''
|
preConfigure = ''
|
||||||
substituteInPlace ./Lib/plat-generic/regen \
|
|
||||||
--replace /usr/include/netinet/in.h \
|
|
||||||
${stdenv.gcc.libc}/include/netinet/in.h
|
|
||||||
'';
|
|
||||||
|
|
||||||
buildInputs =
|
|
||||||
optional (stdenv ? gcc && stdenv.gcc.libc != null) stdenv.gcc.libc ++
|
|
||||||
[ bzip2 openssl ]
|
|
||||||
++ optional zlibSupport zlib;
|
|
||||||
|
|
||||||
ensurePurity =
|
|
||||||
''
|
|
||||||
# Purity.
|
# Purity.
|
||||||
for i in /usr /sw /opt /pkg; do
|
for i in /usr /sw /opt /pkg; do
|
||||||
substituteInPlace ./setup.py --replace $i /no-such-path
|
substituteInPlace ./setup.py --replace $i /no-such-path
|
||||||
done
|
done
|
||||||
|
'' + optionalString (stdenv ? gcc && stdenv.gcc.libc != null) ''
|
||||||
|
for i in Lib/plat-*/regen; do
|
||||||
|
substituteInPlace $i --replace /usr/include/ ${stdenv.gcc.libc}/include/
|
||||||
|
done
|
||||||
|
'' + optionalString stdenv.isCygwin ''
|
||||||
|
# On Cygwin, `make install' tries to read this Makefile.
|
||||||
|
mkdir -p $out/lib/python${majorVersion}/config
|
||||||
|
touch $out/lib/python${majorVersion}/config/Makefile
|
||||||
|
mkdir -p $out/include/python${majorVersion}
|
||||||
|
touch $out/include/python${majorVersion}/pyconfig.h
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
buildInputs =
|
||||||
|
optional (stdenv ? gcc && stdenv.gcc.libc != null) stdenv.gcc.libc ++
|
||||||
|
[ bzip2 openssl ] ++ optionals includeModules [ db openssl ncurses gdbm libX11 readline x11 tcl tk sqlite ]
|
||||||
|
++ optional zlibSupport zlib;
|
||||||
|
|
||||||
# Build the basic Python interpreter without modules that have
|
# Build the basic Python interpreter without modules that have
|
||||||
# external dependencies.
|
# external dependencies.
|
||||||
python = stdenv.mkDerivation {
|
python = stdenv.mkDerivation {
|
||||||
name = "python-${version}";
|
name = "python-${version}";
|
||||||
|
|
||||||
inherit majorVersion version src patches postPatch buildInputs;
|
inherit majorVersion version src patches buildInputs preConfigure;
|
||||||
|
|
||||||
LDFLAGS = stdenv.lib.optionalString (!stdenv.isDarwin) "-lgcc_s";
|
LDFLAGS = stdenv.lib.optionalString (!stdenv.isDarwin) "-lgcc_s";
|
||||||
C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs);
|
C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs);
|
||||||
|
@ -62,15 +64,6 @@ let
|
||||||
|
|
||||||
configureFlags = "--enable-shared --with-threads --enable-unicode";
|
configureFlags = "--enable-shared --with-threads --enable-unicode";
|
||||||
|
|
||||||
preConfigure = "${ensurePurity}" + optionalString stdenv.isCygwin
|
|
||||||
''
|
|
||||||
# On Cygwin, `make install' tries to read this Makefile.
|
|
||||||
mkdir -p $out/lib/python${majorVersion}/config
|
|
||||||
touch $out/lib/python${majorVersion}/config/Makefile
|
|
||||||
mkdir -p $out/include/python${majorVersion}
|
|
||||||
touch $out/include/python${majorVersion}/pyconfig.h
|
|
||||||
'';
|
|
||||||
|
|
||||||
NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin "-msse2";
|
NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin "-msse2";
|
||||||
|
|
||||||
setupHook = ./setup-hook.sh;
|
setupHook = ./setup-hook.sh;
|
||||||
|
@ -83,6 +76,8 @@ let
|
||||||
ln -s $out/share/man/man1/{python2.7.1.gz,python.1.gz}
|
ln -s $out/share/man/man1/{python2.7.1.gz,python.1.gz}
|
||||||
|
|
||||||
paxmark E $out/bin/python${majorVersion}
|
paxmark E $out/bin/python${majorVersion}
|
||||||
|
|
||||||
|
${ optionalString includeModules "$out/bin/python ./setup.py build_ext"}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru = rec {
|
passthru = rec {
|
||||||
|
@ -110,7 +105,7 @@ let
|
||||||
'';
|
'';
|
||||||
license = stdenv.lib.licenses.psfl;
|
license = stdenv.lib.licenses.psfl;
|
||||||
platforms = stdenv.lib.platforms.all;
|
platforms = stdenv.lib.platforms.all;
|
||||||
maintainers = with stdenv.lib.maintainers; [ simons chaoflow ];
|
maintainers = with stdenv.lib.maintainers; [ simons chaoflow iElectric ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -122,25 +117,17 @@ let
|
||||||
, internalName ? "_" + moduleName
|
, internalName ? "_" + moduleName
|
||||||
, deps
|
, deps
|
||||||
}:
|
}:
|
||||||
stdenv.mkDerivation rec {
|
if (includeModules) then null else stdenv.mkDerivation rec {
|
||||||
name = "python-${moduleName}-${python.version}";
|
name = "python-${moduleName}-${python.version}";
|
||||||
|
|
||||||
inherit src patches postPatch;
|
inherit src patches preConfigure;
|
||||||
|
|
||||||
buildInputs = [ python ] ++ deps;
|
buildInputs = [ python ] ++ deps;
|
||||||
|
|
||||||
C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs);
|
C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs);
|
||||||
LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") buildInputs);
|
LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") buildInputs);
|
||||||
|
|
||||||
configurePhase = "${ensurePurity}";
|
buildPhase = ''
|
||||||
|
|
||||||
buildPhase =
|
|
||||||
''
|
|
||||||
# Fake the build environment that setup.py expects.
|
|
||||||
ln -s ${python}/include/python*/pyconfig.h .
|
|
||||||
ln -s ${python}/lib/python*/config/Setup Modules/
|
|
||||||
ln -s ${python}/lib/python*/config/Setup.local Modules/
|
|
||||||
|
|
||||||
substituteInPlace setup.py --replace 'self.extensions = extensions' \
|
substituteInPlace setup.py --replace 'self.extensions = extensions' \
|
||||||
'self.extensions = [ext for ext in self.extensions if ext.name in ["${internalName}"]]'
|
'self.extensions = [ext for ext in self.extensions if ext.name in ["${internalName}"]]'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue