2016-09-01 17:58:14 +01:00
|
|
|
{ stdenv, fetchurl, zlib ? null, zlibSupport ? true, bzip2, includeModules ? false
|
2016-05-29 14:12:23 +01:00
|
|
|
, sqlite, tcl, tk, xlibsWrapper, openssl, readline, db, ncurses, gdbm, self, callPackage
|
2016-12-04 08:51:12 +00:00
|
|
|
# For the Python package set
|
|
|
|
, pkgs, packageOverrides ? (self: super: {})
|
|
|
|
}:
|
2011-04-06 22:57:30 +01:00
|
|
|
|
|
|
|
assert zlibSupport -> zlib != null;
|
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
majorVersion = "2.6";
|
2016-09-20 12:01:30 +01:00
|
|
|
minorVersion = "9";
|
|
|
|
minorVersionSuffix = "";
|
|
|
|
pythonVersion = majorVersion;
|
|
|
|
version = "${majorVersion}.${minorVersion}${minorVersionSuffix}";
|
|
|
|
libPrefix = "python${majorVersion}";
|
2011-04-06 22:57:30 +01:00
|
|
|
|
|
|
|
src = fetchurl {
|
2016-09-20 12:01:30 +01:00
|
|
|
url = "https://www.python.org/ftp/python/${majorVersion}.${minorVersion}/Python-${version}.tar.xz";
|
2014-02-19 23:44:08 +00:00
|
|
|
sha256 = "0hbfs2691b60c7arbysbzr0w9528d5pl8a4x7mq5psh6a2cvprya";
|
2011-04-06 22:57:30 +01:00
|
|
|
};
|
2013-12-23 20:45:46 +00:00
|
|
|
|
2011-04-06 22:57:30 +01:00
|
|
|
patches =
|
|
|
|
[ # Look in C_INCLUDE_PATH and LIBRARY_PATH for stuff.
|
|
|
|
./search-path.patch
|
|
|
|
|
|
|
|
# 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
|
2015-01-18 15:25:43 +00:00
|
|
|
|
|
|
|
# http://bugs.python.org/issue10013
|
|
|
|
./python2.6-fix-parallel-make.patch
|
2011-04-06 22:57:30 +01:00
|
|
|
];
|
2014-10-12 13:58:07 +01:00
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
# Purity.
|
|
|
|
for i in /usr /sw /opt /pkg; do
|
|
|
|
substituteInPlace ./setup.py --replace $i /no-such-path
|
|
|
|
done
|
2014-12-26 17:28:15 +00:00
|
|
|
'' + optionalString (stdenv ? cc && stdenv.cc.libc != null) ''
|
2014-10-12 13:58:07 +01:00
|
|
|
for i in Lib/plat-*/regen; do
|
2014-12-26 17:28:15 +00:00
|
|
|
substituteInPlace $i --replace /usr/include/ ${stdenv.cc.libc}/include/
|
2014-10-12 13:58:07 +01:00
|
|
|
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-04-06 22:57:30 +01:00
|
|
|
|
2015-05-12 16:34:43 +01:00
|
|
|
configureFlags = "--enable-shared --with-threads --enable-unicode=ucs4";
|
|
|
|
|
2011-04-06 22:57:30 +01:00
|
|
|
buildInputs =
|
2014-12-17 18:11:30 +00:00
|
|
|
optional (stdenv ? cc && stdenv.cc.libc != null) stdenv.cc.libc ++
|
2015-09-15 10:13:22 +01:00
|
|
|
[ bzip2 openssl ]++ optionals includeModules [ db openssl ncurses gdbm readline xlibsWrapper tcl tk sqlite ]
|
2012-04-23 16:47:31 +01:00
|
|
|
++ optional zlibSupport zlib;
|
2011-04-06 22:57:30 +01:00
|
|
|
|
2015-04-18 19:59:36 +01:00
|
|
|
mkPaths = paths: {
|
2016-04-14 17:00:39 +01:00
|
|
|
C_INCLUDE_PATH = makeSearchPathOutput "dev" "include" paths;
|
|
|
|
LIBRARY_PATH = makeLibraryPath paths;
|
2015-04-18 19:59:36 +01:00
|
|
|
};
|
2013-12-23 20:45:46 +00:00
|
|
|
|
2011-04-06 22:57:30 +01:00
|
|
|
# Build the basic Python interpreter without modules that have
|
|
|
|
# external dependencies.
|
|
|
|
python = stdenv.mkDerivation {
|
2014-10-12 13:58:07 +01:00
|
|
|
name = "python${if includeModules then "" else "-minimal"}-${version}";
|
2015-01-24 10:38:54 +00:00
|
|
|
pythonVersion = majorVersion;
|
2013-12-23 20:45:46 +00:00
|
|
|
|
2016-09-01 17:58:14 +01:00
|
|
|
inherit majorVersion version src patches buildInputs preConfigure
|
|
|
|
configureFlags;
|
2011-04-06 22:57:30 +01:00
|
|
|
|
2015-04-18 19:59:36 +01:00
|
|
|
inherit (mkPaths buildInputs) C_INCLUDE_PATH LIBRARY_PATH;
|
2011-04-06 22:57:30 +01:00
|
|
|
|
|
|
|
NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin "-msse2";
|
|
|
|
|
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
|
|
|
|
postInstall =
|
|
|
|
''
|
2014-10-23 11:07:07 +01:00
|
|
|
# needed for some packages, especially packages that backport
|
|
|
|
# functionality to 2.x from 3.x
|
|
|
|
for item in $out/lib/python${majorVersion}/test/*; do
|
|
|
|
if [[ "$item" != */test_support.py* ]]; then
|
|
|
|
rm -rf "$item"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
touch $out/lib/python${majorVersion}/test/__init__.py
|
2012-07-20 19:11:04 +01:00
|
|
|
ln -s $out/lib/python${majorVersion}/pdb.py $out/bin/pdb
|
|
|
|
ln -s $out/lib/python${majorVersion}/pdb.py $out/bin/pdb${majorVersion}
|
2013-01-09 07:27:39 +00:00
|
|
|
mv $out/share/man/man1/{python.1,python2.6.1}
|
|
|
|
ln -s $out/share/man/man1/{python2.6.1,python.1}
|
2015-04-18 19:59:36 +01:00
|
|
|
|
2014-10-12 13:58:07 +01:00
|
|
|
paxmark E $out/bin/python${majorVersion}
|
2015-04-18 19:59:36 +01:00
|
|
|
|
2016-09-20 12:16:26 +01:00
|
|
|
# Python on Nix is not manylinux1 compatible. https://github.com/NixOS/nixpkgs/issues/18484
|
|
|
|
echo "manylinux1_compatible=False" >> $out/lib/${libPrefix}/_manylinux.py
|
|
|
|
|
2014-10-12 13:58:07 +01:00
|
|
|
${ optionalString includeModules "$out/bin/python ./setup.py build_ext"}
|
2011-04-06 22:57:30 +01:00
|
|
|
'';
|
|
|
|
|
2016-12-04 08:51:12 +00:00
|
|
|
passthru = let
|
|
|
|
pythonPackages = callPackage ../../../../../top-level/python-packages.nix {python=self; overrides=packageOverrides;};
|
|
|
|
in rec {
|
2016-09-20 12:01:30 +01:00
|
|
|
inherit libPrefix;
|
2011-04-06 22:57:30 +01:00
|
|
|
inherit zlibSupport;
|
2014-07-09 16:34:08 +01:00
|
|
|
isPy2 = true;
|
|
|
|
isPy26 = true;
|
2016-07-07 13:05:05 +01:00
|
|
|
buildEnv = callPackage ../../wrapper.nix { python = self; };
|
2016-12-04 08:51:12 +00:00
|
|
|
withPackages = import ../../with-packages.nix { inherit buildEnv pythonPackages;};
|
|
|
|
pkgs = pythonPackages;
|
2014-07-07 17:39:57 +01:00
|
|
|
executable = libPrefix;
|
|
|
|
sitePackages = "lib/${libPrefix}/site-packages";
|
2014-11-12 23:42:12 +00:00
|
|
|
interpreter = "${self}/bin/${executable}";
|
2011-04-06 22:57:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
homepage = "http://python.org";
|
2016-06-20 11:53:46 +01:00
|
|
|
description = "A high-level dynamically-typed programming language";
|
2011-04-06 22:57:30 +01: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-04-06 22:57:30 +01:00
|
|
|
platforms = stdenv.lib.platforms.all;
|
2016-05-17 12:57:28 +01:00
|
|
|
maintainers = with stdenv.lib.maintainers; [ chaoflow domenkozar ];
|
2015-07-12 05:17:59 +01:00
|
|
|
# If you want to use Python 2.6, remove "broken = true;" at your own
|
|
|
|
# risk. Python 2.6 has known security vulnerabilities is not receiving
|
|
|
|
# security updates as of October 2013.
|
|
|
|
broken = true;
|
2011-04-06 22:57:30 +01: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 17:24:16 +01:00
|
|
|
if includeModules then null else stdenv.mkDerivation rec {
|
2011-04-06 22:57:30 +01:00
|
|
|
name = "python-${moduleName}-${python.version}";
|
|
|
|
|
2015-05-12 16:34:43 +01:00
|
|
|
inherit src patches preConfigure configureFlags;
|
2011-04-06 22:57:30 +01:00
|
|
|
|
|
|
|
buildInputs = [ python ] ++ deps;
|
|
|
|
|
2015-04-18 19:59:36 +01:00
|
|
|
inherit (mkPaths buildInputs) C_INCLUDE_PATH LIBRARY_PATH;
|
2011-04-06 22:57:30 +01:00
|
|
|
|
|
|
|
buildPhase =
|
|
|
|
''
|
|
|
|
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
|
2015-05-12 16:15:34 +01:00
|
|
|
[ -z "$(find build -name '*_failed.so' -print)" ]
|
2011-04-06 22:57:30 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase =
|
|
|
|
''
|
|
|
|
dest=$out/lib/${python.libPrefix}/site-packages
|
|
|
|
mkdir -p $dest
|
|
|
|
cp -p $(find . -name "*.${if stdenv.isCygwin then "dll" else "so"}") $dest/
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
# 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-04-06 22:57:30 +01:00
|
|
|
};
|
|
|
|
|
2013-08-14 07:42:48 +01:00
|
|
|
crypt = buildInternalPythonModule {
|
|
|
|
moduleName = "crypt";
|
|
|
|
internalName = "crypt";
|
2015-05-14 19:21:56 +01:00
|
|
|
deps = optional (stdenv ? glibc) stdenv.glibc;
|
2013-08-14 07:42:48 +01:00
|
|
|
};
|
|
|
|
|
2011-04-06 22:57:30 +01:00
|
|
|
curses = buildInternalPythonModule {
|
|
|
|
moduleName = "curses";
|
|
|
|
deps = [ ncurses ];
|
|
|
|
};
|
|
|
|
|
2013-10-18 09:54:49 +01:00
|
|
|
curses_panel = buildInternalPythonModule {
|
|
|
|
moduleName = "curses_panel";
|
|
|
|
deps = [ ncurses modules.curses ];
|
|
|
|
};
|
|
|
|
|
2011-04-06 22:57:30 +01:00
|
|
|
gdbm = buildInternalPythonModule {
|
|
|
|
moduleName = "gdbm";
|
|
|
|
internalName = "gdbm";
|
|
|
|
deps = [ gdbm ];
|
|
|
|
};
|
|
|
|
|
|
|
|
sqlite3 = buildInternalPythonModule {
|
|
|
|
moduleName = "sqlite3";
|
|
|
|
deps = [ sqlite ];
|
|
|
|
};
|
|
|
|
|
|
|
|
tkinter = buildInternalPythonModule {
|
|
|
|
moduleName = "tkinter";
|
2015-09-15 10:13:22 +01:00
|
|
|
deps = [ tcl tk xlibsWrapper ];
|
2011-04-06 22:57:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
readline = buildInternalPythonModule {
|
|
|
|
moduleName = "readline";
|
|
|
|
internalName = "readline";
|
|
|
|
deps = [ readline ];
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2013-12-23 20:45:46 +00:00
|
|
|
|
2011-04-06 22:57:30 +01:00
|
|
|
in python // { inherit modules; }
|