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:
Frederik Rietdijk
2018-12-31 13:59:20 +01:00
parent f11591afd9
commit efbe87f3ef
7 changed files with 213 additions and 561 deletions

View File

@@ -0,0 +1,106 @@
{ pkgs, lib }:
with pkgs;
(let
# Common passthru for all Python interpreters.
passthruFun =
{ implementation
, libPrefix
, executable
, sourceVersion
, pythonVersion
, packageOverrides
, sitePackages
, pythonForBuild
, self
}: let
pythonPackages = callPackage ../../../top-level/python-packages.nix {
python = self;
overrides = packageOverrides;
};
in rec {
sitePackages = "lib/${libPrefix}/site-packages";
isPy27 = pythonVersion == "2.7";
isPy33 = pythonVersion == "3.3"; # TODO: remove
isPy34 = pythonVersion == "3.4"; # TODO: remove
isPy35 = pythonVersion == "3.5";
isPy36 = pythonVersion == "3.6";
isPy37 = pythonVersion == "3.7";
isPy3k = lib.strings.substring 0 1 pythonVersion == "3";
isPyPy = interpreter == "pypy";
buildEnv = callPackage ./wrapper.nix { python = self; inherit (pythonPackages) requiredPythonModules; };
withPackages = import ./with-packages.nix { inherit buildEnv pythonPackages;};
pkgs = pythonPackages;
interpreter = "${self}/bin/${executable}";
inherit executable implementation libPrefix pythonVersion;
inherit sourceVersion;
pythonAtLeast = lib.versionAtLeast pythonVersion;
pythonOlder = lib.versionOlder pythonVersion;
inherit pythonForBuild;
majorVersion = pythonVersion; # Backwards compatibility. Should be dropped.
};
in {
python27 = callPackage ./cpython/2.7 {
self = python27;
sourceVersion = {
major = "2";
minor = "7";
patch = "15";
suffix = "";
};
sha256 = "0x2mvz9dp11wj7p5ccvmk9s0hzjk2fa1m462p395l4r6bfnb3n92";
inherit (darwin) CF configd;
inherit passthruFun;
};
python35 = callPackage ./cpython {
self = python35;
sourceVersion = {
major = "3";
minor = "5";
patch = "6";
suffix = "";
};
sha256 = "0pqmf51zy2lzhbaj4yya2py2qr653j9152d0rg3p7wi1yl2dwp7m";
inherit (darwin) CF configd;
inherit passthruFun;
};
python36 = callPackage ./cpython {
self = python36;
sourceVersion = {
major = "3";
minor = "6";
patch = "8";
suffix = "";
};
sha256 = "14qi6n5gpcjnwy165wi9hkfcmbadc95ny6bxxldknxwmx50n4i1m";
inherit (darwin) CF configd;
inherit passthruFun;
};
python37 = callPackage ./cpython {
self = python37;
sourceVersion = {
major = "3";
minor = "7";
patch = "2";
suffix = "";
};
sha256 = "1fzi9d2gibh0wzwidyckzbywsxcsbckgsl05ryxlifxia77fhgyq";
inherit (darwin) CF configd;
inherit passthruFun;
};
# pypy27 = callPackage ./pypy {
# self = pypy27;
# implementation = "pypy";
# };
})