2014-10-12 12:58:07 +00:00
|
|
|
{ stdenv, fetchurl, zlib ? null, zlibSupport ? true, bzip2, includeModules ? false
|
2014-01-31 20:05:37 +00:00
|
|
|
, sqlite, tcl, tk, x11, openssl, readline, db, ncurses, gdbm, libX11 }:
|
2010-08-11 15:49:03 +00:00
|
|
|
|
|
|
|
assert zlibSupport -> zlib != null;
|
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
majorVersion = "2.7";
|
2014-07-02 16:44:54 +00:00
|
|
|
version = "${majorVersion}.8";
|
2010-08-11 15:49:03 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2014-02-19 23:44:27 +00:00
|
|
|
url = "http://www.python.org/ftp/python/${version}/Python-${version}.tar.xz";
|
2014-07-02 16:44:54 +00:00
|
|
|
sha256 = "0nh7d3dp75f1aj0pamn4hla8s0l7nbaq4a38brry453xrfh11ppd";
|
2010-08-11 15:49:03 +00:00
|
|
|
};
|
2011-05-05 14:41:08 +00:00
|
|
|
|
2011-01-04 14:47:36 +00:00
|
|
|
patches =
|
|
|
|
[ # Look in C_INCLUDE_PATH and LIBRARY_PATH for stuff.
|
|
|
|
./search-path.patch
|
2011-01-04 15:10:03 +00:00
|
|
|
|
|
|
|
# Python recompiles a Python if the mtime stored *in* the
|
|
|
|
# pyc/pyo file differs from the mtime of the source file. This
|
|
|
|
# doesn't work in Nix because Nix changes the mtime of files in
|
|
|
|
# the Nix store to 1. So treat that as a special case.
|
|
|
|
./nix-store-mtime.patch
|
2013-06-22 05:52:27 +00:00
|
|
|
|
|
|
|
# patch python to put zero timestamp into pyc
|
|
|
|
# if DETERMINISTIC_BUILD env var is set
|
|
|
|
./deterministic-build.patch
|
2014-09-30 07:37:19 +00:00
|
|
|
|
|
|
|
# http://bugs.python.org/issue21963
|
|
|
|
./remove-avoid-daemon-thread-shutdown.patch
|
2011-01-04 14:47:36 +00:00
|
|
|
];
|
2014-10-12 12:58:07 +00:00
|
|
|
|
|
|
|
preConfigure = ''
|
2011-05-05 14:41:15 +00:00
|
|
|
# Purity.
|
|
|
|
for i in /usr /sw /opt /pkg; do
|
|
|
|
substituteInPlace ./setup.py --replace $i /no-such-path
|
|
|
|
done
|
2014-10-12 12:58:07 +00:00
|
|
|
'' + 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
|
2011-05-05 14:41:15 +00:00
|
|
|
'';
|
2011-05-05 14:41:08 +00:00
|
|
|
|
2014-10-12 12:58:07 +00:00
|
|
|
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;
|
|
|
|
|
2011-03-28 09:48:57 +00:00
|
|
|
# Build the basic Python interpreter without modules that have
|
|
|
|
# external dependencies.
|
|
|
|
python = stdenv.mkDerivation {
|
|
|
|
name = "python-${version}";
|
2011-05-05 14:41:08 +00:00
|
|
|
|
2014-10-12 12:58:07 +00:00
|
|
|
inherit majorVersion version src patches buildInputs preConfigure;
|
2011-03-28 09:48:57 +00:00
|
|
|
|
2014-07-02 17:55:39 +00:00
|
|
|
LDFLAGS = stdenv.lib.optionalString (!stdenv.isDarwin) "-lgcc_s";
|
2011-03-28 09:48:57 +00:00
|
|
|
C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs);
|
|
|
|
LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") buildInputs);
|
|
|
|
|
2013-06-21 12:05:46 +00:00
|
|
|
configureFlags = "--enable-shared --with-threads --enable-unicode";
|
2011-03-28 09:48:57 +00:00
|
|
|
|
|
|
|
NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin "-msse2";
|
|
|
|
|
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
|
|
|
|
postInstall =
|
|
|
|
''
|
|
|
|
rm -rf "$out/lib/python${majorVersion}/test"
|
2012-07-20 18:11:04 +00:00
|
|
|
ln -s $out/lib/python${majorVersion}/pdb.py $out/bin/pdb
|
|
|
|
ln -s $out/lib/python${majorVersion}/pdb.py $out/bin/pdb${majorVersion}
|
2012-12-22 02:26:19 +00:00
|
|
|
ln -s $out/share/man/man1/{python2.7.1.gz,python.1.gz}
|
2014-03-17 18:10:00 +00:00
|
|
|
|
|
|
|
paxmark E $out/bin/python${majorVersion}
|
2014-10-12 12:58:07 +00:00
|
|
|
|
|
|
|
${ optionalString includeModules "$out/bin/python ./setup.py build_ext"}
|
2011-03-28 09:48:57 +00:00
|
|
|
'';
|
|
|
|
|
2014-07-07 16:39:57 +00:00
|
|
|
passthru = rec {
|
2011-03-28 09:48:57 +00:00
|
|
|
inherit zlibSupport;
|
2014-07-09 15:34:08 +00:00
|
|
|
isPy2 = true;
|
|
|
|
isPy27 = true;
|
2011-03-28 09:48:57 +00:00
|
|
|
libPrefix = "python${majorVersion}";
|
2014-07-07 16:39:57 +00:00
|
|
|
executable = libPrefix;
|
|
|
|
sitePackages = "lib/${libPrefix}/site-packages";
|
2011-03-28 09:48:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
homepage = "http://python.org";
|
2012-02-26 17:23:16 +00:00
|
|
|
description = "a high-level dynamically-typed programming language";
|
2011-03-28 09:48:57 +00:00
|
|
|
longDescription = ''
|
|
|
|
Python is a remarkably powerful dynamic programming language that
|
|
|
|
is used in a wide variety of application domains. Some of its key
|
|
|
|
distinguishing features include: clear, readable syntax; strong
|
|
|
|
introspection capabilities; intuitive object orientation; natural
|
|
|
|
expression of procedural code; full modularity, supporting
|
|
|
|
hierarchical packages; exception-based error handling; and very
|
|
|
|
high level dynamic data types.
|
|
|
|
'';
|
2012-02-26 17:23:16 +00:00
|
|
|
license = stdenv.lib.licenses.psfl;
|
2011-03-28 09:48:57 +00:00
|
|
|
platforms = stdenv.lib.platforms.all;
|
2014-10-12 12:58:07 +00:00
|
|
|
maintainers = with stdenv.lib.maintainers; [ simons chaoflow iElectric ];
|
2011-03-28 09:48:57 +00:00
|
|
|
};
|
|
|
|
};
|
2010-08-11 15:49:03 +00:00
|
|
|
|
|
|
|
|
2011-03-28 09:48:57 +00:00
|
|
|
# This function builds a Python module included in the main Python
|
|
|
|
# distribution in a separate derivation.
|
|
|
|
buildInternalPythonModule =
|
|
|
|
{ moduleName
|
|
|
|
, internalName ? "_" + moduleName
|
|
|
|
, deps
|
|
|
|
}:
|
2014-10-12 16:24:16 +00:00
|
|
|
if includeModules then null else stdenv.mkDerivation rec {
|
2011-03-28 09:48:57 +00:00
|
|
|
name = "python-${moduleName}-${python.version}";
|
|
|
|
|
2014-10-12 12:58:07 +00:00
|
|
|
inherit src patches preConfigure;
|
2011-03-28 09:48:57 +00:00
|
|
|
|
|
|
|
buildInputs = [ python ] ++ deps;
|
|
|
|
|
|
|
|
C_INCLUDE_PATH = concatStringsSep ":" (map (p: "${p}/include") buildInputs);
|
|
|
|
LIBRARY_PATH = concatStringsSep ":" (map (p: "${p}/lib") buildInputs);
|
|
|
|
|
2014-10-12 12:58:07 +00:00
|
|
|
buildPhase = ''
|
2011-03-28 09:48:57 +00:00
|
|
|
substituteInPlace setup.py --replace 'self.extensions = extensions' \
|
|
|
|
'self.extensions = [ext for ext in self.extensions if ext.name in ["${internalName}"]]'
|
|
|
|
|
|
|
|
python ./setup.py build_ext
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase =
|
|
|
|
''
|
|
|
|
dest=$out/lib/${python.libPrefix}/site-packages
|
|
|
|
mkdir -p $dest
|
2011-04-05 14:29:11 +00:00
|
|
|
cp -p $(find . -name "*.${if stdenv.isCygwin then "dll" else "so"}") $dest/
|
2011-03-28 09:48:57 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
# The Python modules included in the main Python distribution, built
|
|
|
|
# as separate derivations.
|
|
|
|
modules = {
|
|
|
|
|
|
|
|
bsddb = buildInternalPythonModule {
|
|
|
|
moduleName = "bsddb";
|
2014-01-31 20:05:37 +00:00
|
|
|
deps = [ db ];
|
2011-03-28 09:48:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
curses = buildInternalPythonModule {
|
|
|
|
moduleName = "curses";
|
|
|
|
deps = [ ncurses ];
|
|
|
|
};
|
|
|
|
|
2013-10-18 07:11:47 +00:00
|
|
|
curses_panel = buildInternalPythonModule {
|
|
|
|
moduleName = "curses_panel";
|
|
|
|
deps = [ ncurses modules.curses ];
|
|
|
|
};
|
|
|
|
|
2013-08-13 09:13:59 +00:00
|
|
|
crypt = buildInternalPythonModule {
|
|
|
|
moduleName = "crypt";
|
|
|
|
internalName = "crypt";
|
|
|
|
deps = [ ];
|
|
|
|
};
|
|
|
|
|
2011-03-28 09:48:57 +00:00
|
|
|
gdbm = buildInternalPythonModule {
|
|
|
|
moduleName = "gdbm";
|
|
|
|
internalName = "gdbm";
|
|
|
|
deps = [ gdbm ];
|
|
|
|
};
|
|
|
|
|
|
|
|
sqlite3 = buildInternalPythonModule {
|
|
|
|
moduleName = "sqlite3";
|
|
|
|
deps = [ sqlite ];
|
|
|
|
};
|
|
|
|
|
|
|
|
tkinter = buildInternalPythonModule {
|
|
|
|
moduleName = "tkinter";
|
2013-06-29 23:49:55 +00:00
|
|
|
deps = [ tcl tk x11 libX11 ];
|
2011-03-28 09:48:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
readline = buildInternalPythonModule {
|
|
|
|
moduleName = "readline";
|
|
|
|
internalName = "readline";
|
|
|
|
deps = [ readline ];
|
|
|
|
};
|
2010-08-11 15:49:03 +00:00
|
|
|
|
|
|
|
};
|
2011-05-05 14:41:08 +00:00
|
|
|
|
2011-03-28 09:48:57 +00:00
|
|
|
in python // { inherit modules; }
|