2022-10-21 18:38:19 +00:00
|
|
|
{ __splicedPackages
|
|
|
|
, callPackage
|
|
|
|
, config
|
|
|
|
, darwin
|
|
|
|
, db
|
|
|
|
, lib
|
|
|
|
, libffiBoot
|
|
|
|
, newScope
|
|
|
|
, pythonPackagesExtensions
|
|
|
|
, splicePackages
|
|
|
|
, stdenv
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
(let
|
|
|
|
|
|
|
|
# Common passthru for all Python interpreters.
|
|
|
|
passthruFun =
|
|
|
|
{ implementation
|
|
|
|
, libPrefix
|
|
|
|
, executable
|
|
|
|
, sourceVersion
|
|
|
|
, pythonVersion
|
|
|
|
, packageOverrides
|
|
|
|
, sitePackages
|
|
|
|
, hasDistutilsCxxPatch
|
2020-11-30 08:33:03 +00:00
|
|
|
, pythonOnBuildForBuild
|
|
|
|
, pythonOnBuildForHost
|
|
|
|
, pythonOnBuildForTarget
|
|
|
|
, pythonOnHostForHost
|
|
|
|
, pythonOnTargetForTarget
|
2022-08-12 12:06:08 +00:00
|
|
|
, pythonAttr ? null
|
2020-11-30 08:33:03 +00:00
|
|
|
, self # is pythonOnHostForTarget
|
2020-04-24 23:36:52 +00:00
|
|
|
}: let
|
2022-10-30 15:09:59 +00:00
|
|
|
pythonPackages = let
|
|
|
|
ensurePythonModules = items: let
|
|
|
|
exceptions = [
|
|
|
|
stdenv
|
|
|
|
];
|
|
|
|
providesSetupHook = lib.attrByPath [ "provides" "setupHook"] false;
|
|
|
|
valid = value: !((lib.isDerivation value) && !((pythonPackages.hasPythonModule value) || (providesSetupHook value))) || (lib.elem value exceptions);
|
|
|
|
func = name: value: if (valid value) then value else throw "${name} should use `buildPythonPackage` or `toPythonModule` if it is to be part of the Python packages set.";
|
|
|
|
in lib.mapAttrs func items;
|
|
|
|
in ensurePythonModules (callPackage
|
2022-08-12 12:06:08 +00:00
|
|
|
# Function that when called
|
|
|
|
# - imports python-packages.nix
|
|
|
|
# - adds spliced package sets to the package set
|
|
|
|
# - applies overrides from `packageOverrides` and `pythonPackagesOverlays`.
|
2020-11-21 19:51:51 +00:00
|
|
|
({ pkgs, stdenv, python, overrides }: let
|
2022-10-30 15:09:59 +00:00
|
|
|
pythonPackagesFun = import ./python-packages-base.nix {
|
2021-01-15 22:18:51 +00:00
|
|
|
inherit stdenv pkgs lib;
|
2020-11-21 19:51:51 +00:00
|
|
|
python = self;
|
|
|
|
};
|
|
|
|
otherSplices = {
|
2020-11-30 08:33:03 +00:00
|
|
|
selfBuildBuild = pythonOnBuildForBuild.pkgs;
|
|
|
|
selfBuildHost = pythonOnBuildForHost.pkgs;
|
|
|
|
selfBuildTarget = pythonOnBuildForTarget.pkgs;
|
|
|
|
selfHostHost = pythonOnHostForHost.pkgs;
|
|
|
|
selfTargetTarget = pythonOnTargetForTarget.pkgs or {}; # There is no Python TargetTarget.
|
2020-11-21 19:51:51 +00:00
|
|
|
};
|
2022-10-30 15:09:59 +00:00
|
|
|
hooks = import ./hooks/default.nix;
|
|
|
|
keep = lib.extends hooks pythonPackagesFun;
|
2021-05-20 23:08:51 +00:00
|
|
|
extra = _: {};
|
2021-04-26 19:14:03 +00:00
|
|
|
optionalExtensions = cond: as: if cond then as else [];
|
2022-10-30 15:09:59 +00:00
|
|
|
pythonExtension = import ../../../top-level/python-packages.nix;
|
2021-04-26 19:14:03 +00:00
|
|
|
python2Extension = import ../../../top-level/python2-packages.nix;
|
2022-10-30 15:09:59 +00:00
|
|
|
extensions = lib.composeManyExtensions ([
|
|
|
|
pythonExtension
|
|
|
|
] ++ (optionalExtensions (!self.isPy3k) [
|
|
|
|
python2Extension
|
|
|
|
]) ++ pythonPackagesExtensions ++ [
|
|
|
|
overrides
|
|
|
|
]);
|
2022-04-15 01:41:22 +00:00
|
|
|
aliases = self: super: lib.optionalAttrs config.allowAliases (import ../../../top-level/python-aliases.nix lib self super);
|
2020-11-21 19:51:51 +00:00
|
|
|
in lib.makeScopeWithSplicing
|
2022-10-21 18:38:19 +00:00
|
|
|
splicePackages
|
|
|
|
newScope
|
2020-11-21 19:51:51 +00:00
|
|
|
otherSplices
|
|
|
|
keep
|
2021-05-20 23:08:51 +00:00
|
|
|
extra
|
2022-10-30 15:09:59 +00:00
|
|
|
(lib.extends (lib.composeExtensions aliases extensions) keep))
|
2020-11-21 19:51:51 +00:00
|
|
|
{
|
|
|
|
overrides = packageOverrides;
|
2021-08-05 21:33:18 +00:00
|
|
|
python = self;
|
2022-10-30 15:09:59 +00:00
|
|
|
});
|
2020-04-24 23:36:52 +00:00
|
|
|
in rec {
|
|
|
|
isPy27 = pythonVersion == "2.7";
|
|
|
|
isPy35 = pythonVersion == "3.5";
|
|
|
|
isPy36 = pythonVersion == "3.6";
|
|
|
|
isPy37 = pythonVersion == "3.7";
|
|
|
|
isPy38 = pythonVersion == "3.8";
|
|
|
|
isPy39 = pythonVersion == "3.9";
|
2020-10-19 23:25:03 +00:00
|
|
|
isPy310 = pythonVersion == "3.10";
|
2021-12-26 17:43:05 +00:00
|
|
|
isPy311 = pythonVersion == "3.11";
|
2020-04-24 23:36:52 +00:00
|
|
|
isPy2 = lib.strings.substring 0 1 pythonVersion == "2";
|
|
|
|
isPy3 = lib.strings.substring 0 1 pythonVersion == "3";
|
|
|
|
isPy3k = isPy3;
|
|
|
|
isPyPy = lib.hasInfix "pypy" interpreter;
|
|
|
|
|
|
|
|
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 sitePackages;
|
|
|
|
inherit sourceVersion;
|
|
|
|
pythonAtLeast = lib.versionAtLeast pythonVersion;
|
|
|
|
pythonOlder = lib.versionOlder pythonVersion;
|
2020-11-30 08:33:03 +00:00
|
|
|
inherit hasDistutilsCxxPatch;
|
|
|
|
# TODO: rename to pythonOnBuild
|
|
|
|
# Not done immediately because its likely used outside Nixpkgs.
|
2020-12-03 08:41:04 +00:00
|
|
|
pythonForBuild = pythonOnBuildForHost.override { inherit packageOverrides; self = pythonForBuild; };
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
tests = callPackage ./tests.nix {
|
|
|
|
python = self;
|
|
|
|
};
|
2022-08-12 12:06:08 +00:00
|
|
|
|
|
|
|
inherit pythonAttr;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2021-04-05 15:23:46 +00:00
|
|
|
|
|
|
|
sources = {
|
2021-07-21 07:28:18 +00:00
|
|
|
python39 = {
|
|
|
|
sourceVersion = {
|
|
|
|
major = "3";
|
|
|
|
minor = "9";
|
2022-11-02 22:02:43 +00:00
|
|
|
patch = "15";
|
2021-07-21 07:28:18 +00:00
|
|
|
suffix = "";
|
|
|
|
};
|
2022-11-02 22:02:43 +00:00
|
|
|
sha256 = "sha256-Etr/aAlSjZ9hVCFpUEI8njDw5HM2y1fGqgtDh91etLI=";
|
2022-02-10 20:34:41 +00:00
|
|
|
};
|
|
|
|
python310 = {
|
|
|
|
sourceVersion = {
|
|
|
|
major = "3";
|
|
|
|
minor = "10";
|
2022-11-02 22:02:43 +00:00
|
|
|
patch = "8";
|
2022-02-10 20:34:41 +00:00
|
|
|
suffix = "";
|
|
|
|
};
|
2022-11-02 22:02:43 +00:00
|
|
|
sha256 = "sha256-ajDs3lnEcEgBPrWmWMm13sJ3ID0nk2Z/V433Zx9/A/M=";
|
2021-04-05 15:23:46 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
in {
|
|
|
|
|
|
|
|
python27 = callPackage ./cpython/2.7 {
|
2022-10-21 18:38:19 +00:00
|
|
|
self = __splicedPackages.python27;
|
2020-04-24 23:36:52 +00:00
|
|
|
sourceVersion = {
|
|
|
|
major = "2";
|
|
|
|
minor = "7";
|
|
|
|
patch = "18";
|
|
|
|
suffix = "";
|
|
|
|
};
|
|
|
|
sha256 = "0hzgxl94hnflis0d6m4szjx0b52gah7wpmcg5g00q7am6xwhwb5n";
|
|
|
|
inherit (darwin) configd;
|
|
|
|
inherit passthruFun;
|
|
|
|
};
|
|
|
|
|
|
|
|
python37 = callPackage ./cpython {
|
2022-10-21 18:38:19 +00:00
|
|
|
self = __splicedPackages.python37;
|
2020-04-24 23:36:52 +00:00
|
|
|
sourceVersion = {
|
|
|
|
major = "3";
|
|
|
|
minor = "7";
|
2022-10-21 18:38:19 +00:00
|
|
|
patch = "15";
|
2020-04-24 23:36:52 +00:00
|
|
|
suffix = "";
|
|
|
|
};
|
2022-10-21 18:38:19 +00:00
|
|
|
sha256 = "sha256-WRFHWgesK1PXRuiKBxavbStHNJQZGRNuoNM/ucdblxQ=";
|
2020-04-24 23:36:52 +00:00
|
|
|
inherit (darwin) configd;
|
|
|
|
inherit passthruFun;
|
|
|
|
};
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
python38 = callPackage ./cpython {
|
2022-10-21 18:38:19 +00:00
|
|
|
self = __splicedPackages.python38;
|
2022-03-30 09:31:56 +00:00
|
|
|
sourceVersion = {
|
|
|
|
major = "3";
|
|
|
|
minor = "8";
|
2022-10-21 18:38:19 +00:00
|
|
|
patch = "15";
|
2022-03-30 09:31:56 +00:00
|
|
|
suffix = "";
|
|
|
|
};
|
2022-10-21 18:38:19 +00:00
|
|
|
sha256 = "sha256-URT8eRiipeIOtarGlrMMNvQSxu8ksT9cnrngVpgtlVA=";
|
2020-04-24 23:36:52 +00:00
|
|
|
inherit (darwin) configd;
|
|
|
|
inherit passthruFun;
|
2022-03-30 09:31:56 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-07-21 07:28:18 +00:00
|
|
|
python39 = callPackage ./cpython ({
|
2022-10-21 18:38:19 +00:00
|
|
|
self = __splicedPackages.python39;
|
2020-04-24 23:36:52 +00:00
|
|
|
inherit (darwin) configd;
|
|
|
|
inherit passthruFun;
|
2021-07-21 07:28:18 +00:00
|
|
|
} // sources.python39);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
python310 = callPackage ./cpython ({
|
2022-10-21 18:38:19 +00:00
|
|
|
self = __splicedPackages.python310;
|
2020-10-19 23:25:03 +00:00
|
|
|
inherit (darwin) configd;
|
|
|
|
inherit passthruFun;
|
2022-02-10 20:34:41 +00:00
|
|
|
} // sources.python310);
|
2020-10-19 23:25:03 +00:00
|
|
|
|
2021-12-26 17:43:05 +00:00
|
|
|
python311 = callPackage ./cpython {
|
2022-10-21 18:38:19 +00:00
|
|
|
self = __splicedPackages.python311;
|
2021-12-26 17:43:05 +00:00
|
|
|
sourceVersion = {
|
|
|
|
major = "3";
|
|
|
|
minor = "11";
|
|
|
|
patch = "0";
|
2022-10-30 15:09:59 +00:00
|
|
|
suffix = "";
|
2021-12-26 17:43:05 +00:00
|
|
|
};
|
2022-10-30 15:09:59 +00:00
|
|
|
sha256 = "sha256-pX3ILXc1hhe6ZbmEHO4eO0QfOGw3id3AZ27KB38pUcM=";
|
2021-12-26 17:43:05 +00:00
|
|
|
inherit (darwin) configd;
|
|
|
|
inherit passthruFun;
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# Minimal versions of Python (built without optional dependencies)
|
2021-04-05 15:23:46 +00:00
|
|
|
python3Minimal = (callPackage ./cpython ({
|
2022-10-21 18:38:19 +00:00
|
|
|
self = __splicedPackages.python3Minimal;
|
2021-04-05 15:23:46 +00:00
|
|
|
inherit passthruFun;
|
2021-03-09 03:18:52 +00:00
|
|
|
pythonAttr = "python3Minimal";
|
2020-04-24 23:36:52 +00:00
|
|
|
# strip down that python version as much as possible
|
|
|
|
openssl = null;
|
|
|
|
readline = null;
|
|
|
|
ncurses = null;
|
|
|
|
gdbm = null;
|
|
|
|
sqlite = null;
|
|
|
|
configd = null;
|
2021-04-05 15:23:46 +00:00
|
|
|
tzdata = null;
|
2022-10-21 18:38:19 +00:00
|
|
|
libffi = libffiBoot; # without test suite
|
2020-04-24 23:36:52 +00:00
|
|
|
stripConfig = true;
|
|
|
|
stripIdlelib = true;
|
|
|
|
stripTests = true;
|
|
|
|
stripTkinter = true;
|
|
|
|
rebuildBytecode = false;
|
|
|
|
stripBytecode = true;
|
|
|
|
includeSiteCustomize = false;
|
2020-06-18 07:06:33 +00:00
|
|
|
enableOptimizations = false;
|
2021-07-21 07:28:18 +00:00
|
|
|
enableLTO = false;
|
2021-04-05 15:23:46 +00:00
|
|
|
mimetypesSupport = false;
|
2022-06-26 10:26:21 +00:00
|
|
|
} // sources.python310)).overrideAttrs(old: {
|
2022-06-16 17:23:12 +00:00
|
|
|
# TODO(@Artturin): Add this to the main cpython expr
|
|
|
|
strictDeps = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "python3-minimal";
|
|
|
|
});
|
|
|
|
|
|
|
|
pypy27 = callPackage ./pypy {
|
2022-10-21 18:38:19 +00:00
|
|
|
self = __splicedPackages.pypy27;
|
2020-04-24 23:36:52 +00:00
|
|
|
sourceVersion = {
|
|
|
|
major = "7";
|
2020-08-20 17:08:02 +00:00
|
|
|
minor = "3";
|
2022-10-21 18:38:19 +00:00
|
|
|
patch = "9";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2022-10-21 18:38:19 +00:00
|
|
|
|
|
|
|
sha256 = "sha256-ObCXKVb2VIzlgoAZ264SUDwy1svpGivs+I0+QsxSGXs=";
|
2020-04-24 23:36:52 +00:00
|
|
|
pythonVersion = "2.7";
|
|
|
|
db = db.override { dbmSupport = !stdenv.isDarwin; };
|
2022-10-21 18:38:19 +00:00
|
|
|
python = __splicedPackages.python27;
|
2020-04-24 23:36:52 +00:00
|
|
|
inherit passthruFun;
|
|
|
|
inherit (darwin) libunwind;
|
|
|
|
inherit (darwin.apple_sdk.frameworks) Security;
|
|
|
|
};
|
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
pypy39 = callPackage ./pypy {
|
|
|
|
self = __splicedPackages.pypy39;
|
2020-04-24 23:36:52 +00:00
|
|
|
sourceVersion = {
|
|
|
|
major = "7";
|
2020-08-20 17:08:02 +00:00
|
|
|
minor = "3";
|
2022-10-21 18:38:19 +00:00
|
|
|
patch = "9";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2022-10-21 18:38:19 +00:00
|
|
|
|
|
|
|
sha256 = "sha256-Krqh6f4ewOIzyfvDd6DI6aBjQICo9PMOtomDAfZhjBI=";
|
|
|
|
pythonVersion = "3.9";
|
2020-04-24 23:36:52 +00:00
|
|
|
db = db.override { dbmSupport = !stdenv.isDarwin; };
|
2022-10-21 18:38:19 +00:00
|
|
|
python = __splicedPackages.python27;
|
2020-04-24 23:36:52 +00:00
|
|
|
inherit passthruFun;
|
|
|
|
inherit (darwin) libunwind;
|
|
|
|
inherit (darwin.apple_sdk.frameworks) Security;
|
|
|
|
};
|
2022-10-21 18:38:19 +00:00
|
|
|
|
|
|
|
pypy38 = __splicedPackages.pypy39.override {
|
|
|
|
self = __splicedPackages.pythonInterpreters.pypy38;
|
|
|
|
pythonVersion = "3.8";
|
|
|
|
sha256 = "sha256-W12dklbxKhKa+DhOL1gb36s7wPu+OgpIDZwdLpVJDrE=";
|
|
|
|
};
|
|
|
|
pypy37 = __splicedPackages.pypy39.override {
|
|
|
|
self = __splicedPackages.pythonInterpreters.pypy37;
|
2021-12-24 04:21:11 +00:00
|
|
|
pythonVersion = "3.7";
|
2022-10-21 18:38:19 +00:00
|
|
|
sha256 = "sha256-cEJhY7GU7kYAmYbuptlCYJij/7VS2c29PfqmSkc3P0k=";
|
2021-12-24 04:21:11 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-01-19 23:45:15 +00:00
|
|
|
pypy27_prebuilt = callPackage ./pypy/prebuilt_2_7.nix {
|
2020-04-24 23:36:52 +00:00
|
|
|
# Not included at top-level
|
2022-10-21 18:38:19 +00:00
|
|
|
self = __splicedPackages.pythonInterpreters.pypy27_prebuilt;
|
2020-04-24 23:36:52 +00:00
|
|
|
sourceVersion = {
|
|
|
|
major = "7";
|
2020-08-20 17:08:02 +00:00
|
|
|
minor = "3";
|
2022-10-21 18:38:19 +00:00
|
|
|
patch = "9";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2022-10-21 18:38:19 +00:00
|
|
|
|
|
|
|
sha256 = "sha256-FyqSiwCWp+ALfVj1I/VzAMNcPef4IkkeKnvIRTdcI/g="; # linux64
|
2020-04-24 23:36:52 +00:00
|
|
|
pythonVersion = "2.7";
|
|
|
|
inherit passthruFun;
|
|
|
|
};
|
|
|
|
|
2022-10-21 18:38:19 +00:00
|
|
|
pypy39_prebuilt = callPackage ./pypy/prebuilt.nix {
|
2020-04-24 23:36:52 +00:00
|
|
|
# Not included at top-level
|
2022-10-21 18:38:19 +00:00
|
|
|
self = __splicedPackages.pythonInterpreters.pypy38_prebuilt;
|
2020-04-24 23:36:52 +00:00
|
|
|
sourceVersion = {
|
|
|
|
major = "7";
|
2020-08-20 17:08:02 +00:00
|
|
|
minor = "3";
|
2022-10-21 18:38:19 +00:00
|
|
|
patch = "9";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2022-10-21 18:38:19 +00:00
|
|
|
sha256 = "sha256-RoGMs9dLlrNHh1SDQ9Jm4lYrUx3brzMDg7qTD/GTDtU="; # linux64
|
|
|
|
pythonVersion = "3.9";
|
2020-04-24 23:36:52 +00:00
|
|
|
inherit passthruFun;
|
|
|
|
};
|
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
rustpython = callPackage ./rustpython/default.nix {
|
|
|
|
inherit (darwin.apple_sdk.frameworks) SystemConfiguration;
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
})
|