nixpkgs/pkgs/development/interpreters/python/default.nix

302 lines
8.6 KiB
Nix
Raw Normal View History

{ pkgs }:
with pkgs;
(let
# Common passthru for all Python interpreters.
passthruFun =
{ implementation
, libPrefix
, executable
, sourceVersion
, pythonVersion
, packageOverrides
, sitePackages
, hasDistutilsCxxPatch
, pythonOnBuildForBuild
, pythonOnBuildForHost
, pythonOnBuildForTarget
, pythonOnHostForHost
, pythonOnTargetForTarget
, self # is pythonOnHostForTarget
}: let
pythonPackages = callPackage
({ pkgs, stdenv, python, overrides }: let
pythonPackagesFun = import ../../../top-level/python-packages.nix {
inherit stdenv pkgs lib;
python = self;
};
otherSplices = {
selfBuildBuild = pythonOnBuildForBuild.pkgs;
selfBuildHost = pythonOnBuildForHost.pkgs;
selfBuildTarget = pythonOnBuildForTarget.pkgs;
selfHostHost = pythonOnHostForHost.pkgs;
selfTargetTarget = pythonOnTargetForTarget.pkgs or {}; # There is no Python TargetTarget.
};
keep = self: {
# TODO maybe only define these here so nothing is needed to be kept in sync.
inherit (self)
isPy27 isPy35 isPy36 isPy37 isPy38 isPy39 isPy3k isPyPy pythonAtLeast pythonOlder
python bootstrapped-pip buildPythonPackage buildPythonApplication
fetchPypi
hasPythonModule requiredPythonModules makePythonPath disabledIf
toPythonModule toPythonApplication
buildSetupcfg
condaInstallHook
condaUnpackHook
eggUnpackHook
eggBuildHook
eggInstallHook
flitBuildHook
pipBuildHook
pipInstallHook
pytestCheckHook
pythonCatchConflictsHook
pythonImportsCheckHook
pythonNamespacesHook
pythonRecompileBytecodeHook
pythonRemoveBinBytecodeHook
pythonRemoveTestsDirHook
setuptoolsBuildHook
setuptoolsCheckHook
venvShellHook
wheelUnpackHook
wrapPython
pythonPackages
recursivePthLoader
;
};
extra = _: {};
2021-03-24 11:12:48 +00:00
optionalExtensions = cond: as: if cond then as else [];
python2Extension = import ../../../top-level/python2-packages.nix;
extensions = lib.composeManyExtensions ((optionalExtensions (!self.isPy3k) [python2Extension]) ++ [ overrides ]);
2021-03-15 00:00:14 +00:00
aliases = self: super: lib.optionalAttrs (config.allowAliases or true) (import ../../../top-level/python-aliases.nix lib self super);
in lib.makeScopeWithSplicing
pkgs.splicePackages
pkgs.newScope
otherSplices
keep
extra
2021-03-15 00:00:14 +00:00
(lib.extends (lib.composeExtensions aliases extensions) pythonPackagesFun))
{
overrides = packageOverrides;
python = self;
};
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-13 06:28:25 +00:00
isPy310 = pythonVersion == "3.10";
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;
inherit hasDistutilsCxxPatch;
# TODO: rename to pythonOnBuild
# Not done immediately because its likely used outside Nixpkgs.
pythonForBuild = pythonOnBuildForHost.override { inherit packageOverrides; self = pythonForBuild; };
tests = callPackage ./tests.nix {
python = self;
};
};
sources = {
2021-03-13 14:31:22 +00:00
python38 = {
sourceVersion = {
major = "3";
minor = "8";
2021-07-09 22:01:20 +00:00
patch = "11";
suffix = "";
};
2021-07-09 22:01:20 +00:00
sha256 = "1chg8b0m1yrz50lizid20zha0dmj40z0iih3jqcrg7pyxca126pv";
};
2021-03-13 14:31:22 +00:00
python39 = {
sourceVersion = {
major = "3";
minor = "9";
2021-07-09 22:01:41 +00:00
patch = "6";
2021-03-13 14:31:22 +00:00
suffix = "";
};
2021-07-09 22:01:41 +00:00
sha256 = "12hhw2685i68pwfx5hdkqngzhbji4ccyjmqb5rzvkigg6fpj0y9r";
2021-03-13 14:31:22 +00:00
};
};
in {
python27 = callPackage ./cpython/2.7 {
self = python27;
sourceVersion = {
major = "2";
minor = "7";
2020-04-21 06:30:23 +00:00
patch = "18";
suffix = "";
};
2020-04-21 06:30:23 +00:00
sha256 = "0hzgxl94hnflis0d6m4szjx0b52gah7wpmcg5g00q7am6xwhwb5n";
inherit (darwin) configd;
inherit passthruFun;
};
python36 = callPackage ./cpython {
self = python36;
sourceVersion = {
major = "3";
minor = "6";
2021-07-09 22:01:56 +00:00
patch = "14";
suffix = "";
};
2021-07-09 22:01:56 +00:00
sha256 = "1bnm0bx7xf1jpfm0bmzlq19vwm0bvcbl7klx4rvgq05xryhafqr6";
inherit (darwin) configd;
inherit passthruFun;
};
python37 = callPackage ./cpython {
self = python37;
sourceVersion = {
major = "3";
minor = "7";
2021-07-09 22:02:07 +00:00
patch = "11";
suffix = "";
};
2021-07-09 22:02:07 +00:00
sha256 = "0d57b5a47wapzpkkq5rbvvi4caylc35j5910b64rxxn4nmm1kd6x";
inherit (darwin) configd;
inherit passthruFun;
};
python38 = callPackage ./cpython ({
2019-07-09 13:19:19 +00:00
self = python38;
inherit (darwin) configd;
2019-07-09 13:19:19 +00:00
inherit passthruFun;
} // sources.python38);
2019-07-09 13:19:19 +00:00
2021-03-13 14:31:22 +00:00
python39 = callPackage ./cpython ({
self = python39;
inherit (darwin) configd;
inherit passthruFun;
2021-03-13 14:31:22 +00:00
} // sources.python39);
2020-10-13 06:28:25 +00:00
python310 = callPackage ./cpython {
self = python310;
sourceVersion = {
major = "3";
minor = "10";
patch = "0";
2021-06-17 03:01:49 +00:00
suffix = "b3";
2020-10-13 06:28:25 +00:00
};
2021-06-17 03:01:49 +00:00
sha256 = "05fc4mp2ysb372bzkwbn1b1z01bfldnaqig6rxmif58hs3aawrr2";
2020-10-13 06:28:25 +00:00
inherit (darwin) configd;
inherit passthruFun;
};
# Minimal versions of Python (built without optional dependencies)
python3Minimal = (callPackage ./cpython ({
self = python3Minimal;
inherit passthruFun;
pythonAttr = "python3Minimal";
# strip down that python version as much as possible
openssl = null;
readline = null;
ncurses = null;
gdbm = null;
sqlite = null;
configd = null;
tzdata = null;
stripConfig = true;
stripIdlelib = true;
stripTests = true;
stripTkinter = true;
rebuildBytecode = false;
stripBytecode = true;
includeSiteCustomize = false;
enableOptimizations = false;
cpython: Enable LTO on all builds as it doesn't break reproducibility LTO allows us to optimise the binaries we are shipping a bit further than just with the regular -Ox and other compiler flags. It also is deterministic and doesn't harm our reproducibility efforts while providing us with up to 10% performance gain (and sometimes slightly slower). See the table below for a comparsion of this version with the Python 3.9 build that sets -fno-semantic-interposition. +-------------------------+--------------------+------------------------+--------------+------------------------+ | Benchmark | py39-nsip.nix.json | py39-nsip-lto.nix.json | Change | Significance | +=========================+====================+========================+==============+========================+ | 2to3 | 642 ms | 620 ms | 1.03x faster | Significant (t=12.04) | +-------------------------+--------------------+------------------------+--------------+------------------------+ | chameleon | 14.6 ms | 14.4 ms | 1.02x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | chaos | 182 ms | 182 ms | 1.00x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | crypto_pyaes | 175 ms | 172 ms | 1.02x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | deltablue | 11.2 ms | 11.2 ms | 1.00x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | django_template | 82.0 ms | 81.4 ms | 1.01x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | dulwich_log | 101 ms | 99.8 ms | 1.01x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | fannkuch | 634 ms | 638 ms | 1.01x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | float | 176 ms | 189 ms | 1.08x slower | Significant (t=-4.30) | +-------------------------+--------------------+------------------------+--------------+------------------------+ | go | 366 ms | 365 ms | 1.00x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | hexiom | 14.9 ms | 15.1 ms | 1.01x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | json_dumps | 18.7 ms | 18.5 ms | 1.01x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | json_loads | 37.9 us | 37.3 us | 1.02x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | logging_format | 14.2 us | 14.3 us | 1.01x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | logging_silent | 305 ns | 313 ns | 1.02x slower | Significant (t=-3.91) | +-------------------------+--------------------+------------------------+--------------+------------------------+ | logging_simple | 13.0 us | 13.2 us | 1.01x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | mako | 24.7 ms | 23.3 ms | 1.06x faster | Significant (t=10.74) | +-------------------------+--------------------+------------------------+--------------+------------------------+ | meteor_contest | 130 ms | 128 ms | 1.01x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | nbody | 201 ms | 201 ms | 1.00x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | nqueens | 152 ms | 154 ms | 1.01x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | pathlib | 26.3 ms | 26.2 ms | 1.01x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | pickle | 13.1 us | 13.7 us | 1.05x slower | Significant (t=-10.36) | +-------------------------+--------------------+------------------------+--------------+------------------------+ | pickle_dict | 26.6 us | 27.1 us | 1.02x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | pickle_list | 4.34 us | 4.31 us | 1.01x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | pickle_pure_python | 738 us | 759 us | 1.03x slower | Significant (t=-5.26) | +-------------------------+--------------------+------------------------+--------------+------------------------+ | pidigits | 181 ms | 181 ms | 1.00x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | pyflate | 959 ms | 974 ms | 1.02x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | python_startup | 34.0 ms | 31.4 ms | 1.08x faster | Significant (t=29.75) | +-------------------------+--------------------+------------------------+--------------+------------------------+ | python_startup_no_site | 15.3 ms | 14.5 ms | 1.06x faster | Significant (t=17.58) | +-------------------------+--------------------+------------------------+--------------+------------------------+ | raytrace | 849 ms | 846 ms | 1.00x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | regex_compile | 261 ms | 261 ms | 1.00x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | regex_dna | 187 ms | 221 ms | 1.18x slower | Significant (t=-46.94) | +-------------------------+--------------------+------------------------+--------------+------------------------+ | regex_effbot | 3.66 ms | 3.98 ms | 1.09x slower | Significant (t=-18.55) | +-------------------------+--------------------+------------------------+--------------+------------------------+ | regex_v8 | 29.7 ms | 29.3 ms | 1.01x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | richards | 113 ms | 110 ms | 1.03x faster | Significant (t=3.47) | +-------------------------+--------------------+------------------------+--------------+------------------------+ | scimark_fft | 592 ms | 590 ms | 1.00x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | scimark_lu | 253 ms | 265 ms | 1.05x slower | Significant (t=-8.97) | +-------------------------+--------------------+------------------------+--------------+------------------------+ | scimark_monte_carlo | 170 ms | 177 ms | 1.04x slower | Significant (t=-4.96) | +-------------------------+--------------------+------------------------+--------------+------------------------+ | scimark_sor | 310 ms | 315 ms | 1.02x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | scimark_sparse_mat_mult | 8.36 ms | 8.33 ms | 1.00x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | spectral_norm | 232 ms | 229 ms | 1.02x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | sqlalchemy_declarative | 185 ms | 183 ms | 1.01x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | sqlalchemy_imperative | 27.4 ms | 27.6 ms | 1.01x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | sqlite_synth | 4.73 us | 4.73 us | 1.00x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | sympy_expand | 813 ms | 819 ms | 1.01x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | sympy_integrate | 31.6 ms | 31.8 ms | 1.01x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | sympy_str | 477 ms | 479 ms | 1.00x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | sympy_sum | 245 ms | 247 ms | 1.01x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | telco | 11.3 ms | 11.4 ms | 1.00x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | tornado_http | 172 ms | 172 ms | 1.00x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | unpack_sequence | 56.2 ns | 51.2 ns | 1.10x faster | Significant (t=2.50) | +-------------------------+--------------------+------------------------+--------------+------------------------+ | unpickle | 19.8 us | 19.5 us | 1.02x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | unpickle_list | 5.75 us | 5.75 us | 1.00x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | unpickle_pure_python | 524 us | 522 us | 1.01x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | xml_etree_generate | 148 ms | 148 ms | 1.00x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | xml_etree_iterparse | 129 ms | 131 ms | 1.02x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | xml_etree_parse | 179 ms | 177 ms | 1.01x faster | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+ | xml_etree_process | 118 ms | 119 ms | 1.00x slower | Not significant | +-------------------------+--------------------+------------------------+--------------+------------------------+
2021-05-25 18:30:28 +00:00
enableLTO = false;
2021-03-14 12:00:44 +00:00
mimetypesSupport = false;
2021-03-13 14:31:22 +00:00
} // sources.python39)).overrideAttrs(old: {
pname = "python3-minimal";
meta = old.meta // {
maintainers = [];
};
});
pypy27 = callPackage ./pypy {
self = pypy27;
sourceVersion = {
major = "7";
minor = "3";
2021-07-14 23:37:37 +00:00
patch = "5";
};
2021-07-14 23:37:37 +00:00
sha256 = "sha256-wERP2YcwWMHA2Z4TqTTpIoXLBZksmWi/Ujwyv5vsCp0=";
pythonVersion = "2.7";
2019-10-26 09:20:00 +00:00
db = db.override { dbmSupport = !stdenv.isDarwin; };
python = python27;
inherit passthruFun;
2019-10-26 09:20:00 +00:00
inherit (darwin) libunwind;
inherit (darwin.apple_sdk.frameworks) Security;
};
2021-07-15 03:37:23 +00:00
pypy37 = callPackage ./pypy {
self = pypy37;
sourceVersion = {
major = "7";
minor = "3";
2021-07-14 23:37:37 +00:00
patch = "5";
};
2021-07-14 23:37:37 +00:00
sha256 = "sha256-2SD+QJqeytnQdKqFaMpfPtNYG+ZvZuXYmIt+xm5tmaI=";
2021-07-15 03:37:23 +00:00
pythonVersion = "3.7";
2019-10-26 09:20:00 +00:00
db = db.override { dbmSupport = !stdenv.isDarwin; };
python = python27;
inherit passthruFun;
2019-10-26 09:20:00 +00:00
inherit (darwin) libunwind;
inherit (darwin.apple_sdk.frameworks) Security;
};
pypy27_prebuilt = callPackage ./pypy/prebuilt.nix {
# Not included at top-level
self = pythonInterpreters.pypy27_prebuilt;
sourceVersion = {
major = "7";
minor = "3";
patch = "3";
};
sha256 = "1cfpdyvbvzwc0ynjr7248jhwgcpl7073wlp7w3g2v4fnrh1bc4pl"; # linux64
pythonVersion = "2.7";
inherit passthruFun;
};
pypy36_prebuilt = callPackage ./pypy/prebuilt.nix {
# Not included at top-level
self = pythonInterpreters.pypy36_prebuilt;
sourceVersion = {
major = "7";
minor = "3";
patch = "3";
};
sha256 = "02lys9bjky9bqg6ggv8djirbd3zzcsq7755v4yvwm0k4a7fmzf2g"; # linux64
pythonVersion = "3.6";
inherit passthruFun;
};
graalpython37 = callPackage ./graalpython/default.nix {
self = pythonInterpreters.graalpython37;
inherit passthruFun;
};
2019-03-04 07:56:15 +00:00
})