3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/interpreters/python/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

307 lines
8.9 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)
2021-10-05 01:07:35 +01:00
isPy27 isPy35 isPy36 isPy37 isPy38 isPy39 isPy310 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 ]);
aliases = self: super: lib.optionalAttrs config.allowAliases (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 07:28:25 +01:00
isPy310 = pythonVersion == "3.10";
2021-11-13 13:28:38 +00:00
isPy311 = pythonVersion == "3.11";
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
python39 = {
sourceVersion = {
major = "3";
minor = "9";
patch = "13";
2021-03-13 14:31:22 +00:00
suffix = "";
};
sha256 = "sha256-ElsMWY8eFdKqZUBug/eS330XHN84wWgDsUmZQxajCA8=";
2022-01-15 08:50:12 +00:00
};
2022-01-15 08:50:35 +00:00
python310 = {
sourceVersion = {
major = "3";
minor = "10";
patch = "4";
2022-01-15 08:50:35 +00:00
suffix = "";
};
sha256 = "sha256-gL+SX1cdpDazUhCIbPefbrX6XWxXExa3NWg0NFH3ehk=";
2021-03-13 14:31:22 +00:00
};
};
in {
python27 = callPackage ./cpython/2.7 {
self = python27;
sourceVersion = {
major = "2";
minor = "7";
2020-04-21 07:30:23 +01:00
patch = "18";
suffix = "";
};
2020-04-21 07:30:23 +01:00
sha256 = "0hzgxl94hnflis0d6m4szjx0b52gah7wpmcg5g00q7am6xwhwb5n";
inherit (darwin) configd;
inherit passthruFun;
};
python37 = callPackage ./cpython {
self = python37;
sourceVersion = {
major = "3";
minor = "7";
patch = "13";
suffix = "";
};
sha256 = "sha256-mfEGJ134iZw+jLnXwBzmhsIC7ydZUzAUJxlGk95b74Q=";
inherit (darwin) configd;
inherit passthruFun;
};
python38 = callPackage ./cpython {
2019-07-09 14:19:19 +01:00
self = python38;
sourceVersion = {
major = "3";
minor = "8";
patch = "13";
suffix = "";
};
sha256 = "sha256-bzCQdwEgQKo5/o8MYduMD6HEUTZ2MpnTdcnldW8Jz1c=";
inherit (darwin) configd;
2019-07-09 14:19:19 +01:00
inherit passthruFun;
};
2019-07-09 14:19:19 +01: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);
2022-01-15 08:50:35 +00:00
python310 = callPackage ./cpython ({
2020-10-13 07:28:25 +01:00
self = python310;
inherit (darwin) configd;
inherit passthruFun;
2022-01-15 08:50:35 +00:00
} // sources.python310);
2020-10-13 07:28:25 +01:00
2021-11-13 13:28:38 +00:00
python311 = callPackage ./cpython {
self = python311;
sourceVersion = {
major = "3";
minor = "11";
patch = "0";
suffix = "b3";
2021-11-13 13:28:38 +00:00
};
sha256 = "sha256-ybmfUxXqMPjp/LzmgHo3Oeh1SA0pEk5tmUD2+ry3yQI=";
2021-11-13 13:28:38 +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;
2021-12-17 04:44:56 +00:00
libffi = pkgs.libffiBoot; # without test suite
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 19:30:28 +01:00
enableLTO = false;
2021-03-14 12:00:44 +00:00
mimetypesSupport = false;
2022-05-29 19:17:02 +01:00
} // sources.python310)).overrideAttrs(old: {
# TODO(@Artturin): Add this to the main cpython expr
strictDeps = true;
pname = "python3-minimal";
});
pypy27 = callPackage ./pypy {
self = pypy27;
sourceVersion = {
major = "7";
minor = "3";
2021-07-15 00:37:37 +01:00
patch = "5";
};
2021-07-15 00:37:37 +01:00
sha256 = "sha256-wERP2YcwWMHA2Z4TqTTpIoXLBZksmWi/Ujwyv5vsCp0=";
pythonVersion = "2.7";
2019-10-26 10:20:00 +01:00
db = db.override { dbmSupport = !stdenv.isDarwin; };
python = python27;
inherit passthruFun;
2019-10-26 10:20:00 +01:00
inherit (darwin) libunwind;
inherit (darwin.apple_sdk.frameworks) Security;
};
pypy38 = callPackage ./pypy {
self = pypy38;
sourceVersion = {
major = "7";
minor = "3";
patch = "7";
};
sha256 = "sha256-Ia4zn09QFtbKcwAwXz47VUNzg1yzw5qQQf4w5oEcgMY=";
pythonVersion = "3.8";
2019-10-26 10:20:00 +01:00
db = db.override { dbmSupport = !stdenv.isDarwin; };
python = python27;
inherit passthruFun;
2019-10-26 10:20:00 +01:00
inherit (darwin) libunwind;
inherit (darwin.apple_sdk.frameworks) Security;
};
2021-12-21 23:45:39 +00:00
pypy37 = pypy38.override {
self = pythonInterpreters.pypy37;
pythonVersion = "3.7";
sha256 = "sha256-LtAqyecQhZxBvILer7CGGXkruaJ+6qFnbHQe3t0hTdc=";
};
pypy27_prebuilt = callPackage ./pypy/prebuilt_2_7.nix {
# Not included at top-level
self = pythonInterpreters.pypy27_prebuilt;
sourceVersion = {
major = "7";
minor = "3";
2022-02-22 02:52:09 +00:00
patch = "8";
};
2022-02-22 02:52:09 +00:00
sha256 = "0h493q0lhpz035afi4g09f4mz5a72vqx4sa7qcry5z4zagxq8bhz"; # linux64
pythonVersion = "2.7";
inherit passthruFun;
};
pypy38_prebuilt = callPackage ./pypy/prebuilt.nix {
# Not included at top-level
self = pythonInterpreters.pypy38_prebuilt;
sourceVersion = {
major = "7";
minor = "3";
patch = "7";
};
sha256 = "sha256-Xe43x8PLixYAKPveOlkBxoBD36VFoWeUUCuJfUvEDX4="; # linux64
pythonVersion = "3.8";
inherit passthruFun;
};
rustpython = callPackage ./rustpython/default.nix {
inherit (darwin.apple_sdk.frameworks) SystemConfiguration;
};
2019-03-04 07:56:15 +00:00
})