CPython: merge expressions of interpreters
Each time a new major/minor version of CPython was released, a new expression would be written, typically copied from the previous release. Often fixes are only made in the current/latest release. By merging the expressions it's more likely that modifications end up in all versions, as is likely intended. This commit introduces one expression for Python 3, and another for 2.7. These two may also be merged, but it will result in a lot of extra conditionals making the expression harder to follow. A common passthru is introduced for CPython and PyPy. python 2.7: use common passthru
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
{ stdenv, buildPackages, fetchurl
|
||||
{ stdenv, fetchurl, fetchpatch
|
||||
, bzip2
|
||||
, expat
|
||||
, libffi
|
||||
, gdbm
|
||||
, fetchpatch
|
||||
, db
|
||||
, ncurses
|
||||
, openssl
|
||||
, readline
|
||||
@@ -10,15 +12,16 @@
|
||||
, zlib
|
||||
, callPackage
|
||||
, self
|
||||
, db
|
||||
, expat
|
||||
, libffi
|
||||
, CF, configd, coreutils
|
||||
, python-setup-hook
|
||||
# Some proprietary libs assume UCS2 unicode, especially on darwin :(
|
||||
, ucsEncoding ? 4
|
||||
# For the Python package set
|
||||
, packageOverrides ? (self: super: {})
|
||||
, buildPackages
|
||||
, sourceVersion
|
||||
, sha256
|
||||
, passthruFun
|
||||
}:
|
||||
|
||||
assert x11Support -> tcl != null
|
||||
@@ -29,16 +32,23 @@ assert x11Support -> tcl != null
|
||||
with stdenv.lib;
|
||||
|
||||
let
|
||||
majorVersion = "2.7";
|
||||
minorVersion = "15";
|
||||
minorVersionSuffix = "";
|
||||
version = "${majorVersion}.${minorVersion}${minorVersionSuffix}";
|
||||
libPrefix = "python${majorVersion}";
|
||||
sitePackages = "lib/${libPrefix}/site-packages";
|
||||
passthru = passthruFun rec {
|
||||
inherit self sourceVersion packageOverrides;
|
||||
implementation = "cpython";
|
||||
libPrefix = "python${pythonVersion}";
|
||||
executable = libPrefix;
|
||||
pythonVersion = with sourceVersion; "${major}.${minor}";
|
||||
sitePackages = "lib/${libPrefix}/site-packages";
|
||||
inherit pythonForBuild;
|
||||
} // {
|
||||
inherit ucsEncoding;
|
||||
};
|
||||
|
||||
version = with sourceVersion; "${major}.${minor}.${patch}${suffix}";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://www.python.org/ftp/python/${majorVersion}.${minorVersion}/Python-${version}.tar.xz";
|
||||
sha256 = "0x2mvz9dp11wj7p5ccvmk9s0hzjk2fa1m462p395l4r6bfnb3n92";
|
||||
url = with sourceVersion; "https://www.python.org/ftp/python/${major}.${minor}.${patch}/Python-${version}.tar.xz";
|
||||
inherit sha256;
|
||||
};
|
||||
|
||||
hasDistutilsCxxPatch = !(stdenv.cc.isGNU or false);
|
||||
@@ -191,12 +201,11 @@ let
|
||||
# Build the basic Python interpreter without modules that have
|
||||
# external dependencies.
|
||||
|
||||
in stdenv.mkDerivation ({
|
||||
name = "python-${version}";
|
||||
pythonVersion = majorVersion;
|
||||
in with passthru; stdenv.mkDerivation ({
|
||||
pname = "python";
|
||||
inherit version;
|
||||
|
||||
inherit majorVersion version src patches buildInputs nativeBuildInputs
|
||||
preConfigure configureFlags;
|
||||
inherit src patches buildInputs nativeBuildInputs preConfigure configureFlags;
|
||||
|
||||
LDFLAGS = stdenv.lib.optionalString (!stdenv.isDarwin) "-lgcc_s";
|
||||
inherit (mkPaths buildInputs) C_INCLUDE_PATH LIBRARY_PATH;
|
||||
@@ -215,7 +224,7 @@ in stdenv.mkDerivation ({
|
||||
''
|
||||
# needed for some packages, especially packages that backport
|
||||
# functionality to 2.x from 3.x
|
||||
for item in $out/lib/python${majorVersion}/test/*; do
|
||||
for item in $out/lib/${libPrefix}/test/*; do
|
||||
if [[ "$item" != */test_support.py*
|
||||
&& "$item" != */test/support
|
||||
&& "$item" != */test/regrtest.py* ]]; then
|
||||
@@ -224,9 +233,9 @@ in stdenv.mkDerivation ({
|
||||
echo $item
|
||||
fi
|
||||
done
|
||||
touch $out/lib/python${majorVersion}/test/__init__.py
|
||||
ln -s $out/lib/python${majorVersion}/pdb.py $out/bin/pdb
|
||||
ln -s $out/lib/python${majorVersion}/pdb.py $out/bin/pdb${majorVersion}
|
||||
touch $out/lib/${libPrefix}/test/__init__.py
|
||||
ln -s $out/lib/${libPrefix}/pdb.py $out/bin/pdb
|
||||
ln -s $out/lib/${libPrefix}/pdb.py $out/bin/pdb${sourceVersion.major}.${sourceVersion.minor}
|
||||
ln -s $out/share/man/man1/{python2.7.1.gz,python.1.gz}
|
||||
|
||||
# Python on Nix is not manylinux1 compatible. https://github.com/NixOS/nixpkgs/issues/18484
|
||||
@@ -249,21 +258,7 @@ in stdenv.mkDerivation ({
|
||||
cp libpython2.7.dll.a $out/lib
|
||||
'';
|
||||
|
||||
passthru = let
|
||||
pythonPackages = callPackage ../../../../../top-level/python-packages.nix {
|
||||
python = self;
|
||||
overrides = packageOverrides;
|
||||
};
|
||||
in rec {
|
||||
inherit libPrefix sitePackages x11Support hasDistutilsCxxPatch ucsEncoding;
|
||||
executable = libPrefix;
|
||||
buildEnv = callPackage ../../wrapper.nix { python = self; inherit (pythonPackages) requiredPythonModules; };
|
||||
withPackages = import ../../with-packages.nix { inherit buildEnv pythonPackages;};
|
||||
pkgs = pythonPackages;
|
||||
isPy2 = true;
|
||||
isPy27 = true;
|
||||
interpreter = "${self}/bin/${executable}";
|
||||
};
|
||||
inherit passthru;
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user