1{ pkgs }:
2
3with pkgs;
4
5(let
6
7 # Common passthru for all Python interpreters.
8 passthruFun =
9 { implementation
10 , libPrefix
11 , executable
12 , sourceVersion
13 , pythonVersion
14 , packageOverrides
15 , sitePackages
16 , hasDistutilsCxxPatch
17 , pythonForBuild
18 , self
19 }: let
20 pythonPackages = callPackage ../../../top-level/python-packages.nix {
21 python = self;
22 overrides = packageOverrides;
23 };
24 in rec {
25 isPy27 = pythonVersion == "2.7";
26 isPy35 = pythonVersion == "3.5";
27 isPy36 = pythonVersion == "3.6";
28 isPy37 = pythonVersion == "3.7";
29 isPy38 = pythonVersion == "3.8";
30 isPy39 = pythonVersion == "3.9";
31 isPy2 = lib.strings.substring 0 1 pythonVersion == "2";
32 isPy3 = lib.strings.substring 0 1 pythonVersion == "3";
33 isPy3k = isPy3;
34 isPyPy = lib.hasInfix "pypy" interpreter;
35
36 buildEnv = callPackage ./wrapper.nix { python = self; inherit (pythonPackages) requiredPythonModules; };
37 withPackages = import ./with-packages.nix { inherit buildEnv pythonPackages;};
38 pkgs = pythonPackages;
39 interpreter = "${self}/bin/${executable}";
40 inherit executable implementation libPrefix pythonVersion sitePackages;
41 inherit sourceVersion;
42 pythonAtLeast = lib.versionAtLeast pythonVersion;
43 pythonOlder = lib.versionOlder pythonVersion;
44 inherit hasDistutilsCxxPatch pythonForBuild;
45
46 tests = callPackage ./tests.nix {
47 python = self;
48 };
49 };
50
51in {
52
53 python27 = callPackage ./cpython/2.7 {
54 self = python27;
55 sourceVersion = {
56 major = "2";
57 minor = "7";
58 patch = "18";
59 suffix = "";
60 };
61 sha256 = "0hzgxl94hnflis0d6m4szjx0b52gah7wpmcg5g00q7am6xwhwb5n";
62 inherit (darwin) configd;
63 inherit passthruFun;
64 };
65
66 python36 = callPackage ./cpython {
67 self = python36;
68 sourceVersion = {
69 major = "3";
70 minor = "6";
71 patch = "12";
72 suffix = "";
73 };
74 sha256 = "cJU6m11okdkuZdGEw1EhJqFYFL7hXh7/LdzOBDNOmpk=";
75 inherit (darwin) configd;
76 inherit passthruFun;
77 };
78
79 python37 = callPackage ./cpython {
80 self = python37;
81 sourceVersion = {
82 major = "3";
83 minor = "7";
84 patch = "9";
85 suffix = "";
86 };
87 sha256 = "008v6g1jkrjrdmiqlgjlq6msbbj848bvkws6ppwva1ahn03k14li";
88 inherit (darwin) configd;
89 inherit passthruFun;
90 };
91
92 python38 = callPackage ./cpython {
93 self = python38;
94 sourceVersion = {
95 major = "3";
96 minor = "8";
97 patch = "5";
98 suffix = "";
99 };
100 sha256 = "1c43dbv9lvlp3ynqmgdi4rh8q94swanhqarqrdx62zmigpakw073";
101 inherit (darwin) configd;
102 inherit passthruFun;
103 };
104
105 python39 = callPackage ./cpython {
106 self = python39;
107 sourceVersion = {
108 major = "3";
109 minor = "9";
110 patch = "0";
111 suffix = "";
112 };
113 sha256 = "0m18z05nlmqm1zjw9s0ifgrn1jvjn3jwjg0bpswhjmw5k4yfcwww";
114 inherit (darwin) configd;
115 inherit passthruFun;
116 };
117
118 # Minimal versions of Python (built without optional dependencies)
119 python3Minimal = (python38.override {
120 self = python3Minimal;
121 pythonForBuild = pkgs.buildPackages.python3Minimal;
122 # strip down that python version as much as possible
123 openssl = null;
124 readline = null;
125 ncurses = null;
126 gdbm = null;
127 sqlite = null;
128 configd = null;
129 stripConfig = true;
130 stripIdlelib = true;
131 stripTests = true;
132 stripTkinter = true;
133 rebuildBytecode = false;
134 stripBytecode = true;
135 includeSiteCustomize = false;
136 enableOptimizations = false;
137 }).overrideAttrs(old: {
138 pname = "python3-minimal";
139 meta = old.meta // {
140 maintainers = [];
141 };
142 });
143
144 pypy27 = callPackage ./pypy {
145 self = pypy27;
146 sourceVersion = {
147 major = "7";
148 minor = "3";
149 patch = "1";
150 };
151 sha256 = "08ckkhd0ix6j9873a7gr507c72d4cmnv5lwvprlljdca9i8p2dzs";
152 pythonVersion = "2.7";
153 db = db.override { dbmSupport = !stdenv.isDarwin; };
154 python = python27;
155 inherit passthruFun;
156 inherit (darwin) libunwind;
157 inherit (darwin.apple_sdk.frameworks) Security;
158 };
159
160 pypy36 = callPackage ./pypy {
161 self = pypy36;
162 sourceVersion = {
163 major = "7";
164 minor = "3";
165 patch = "1";
166 };
167 sha256 = "10zsk8jby8j6visk5mzikpb1cidvz27qq4pfpa26jv53klic6b0c";
168 pythonVersion = "3.6";
169 db = db.override { dbmSupport = !stdenv.isDarwin; };
170 python = python27;
171 inherit passthruFun;
172 inherit (darwin) libunwind;
173 inherit (darwin.apple_sdk.frameworks) Security;
174 };
175
176 pypy27_prebuilt = callPackage ./pypy/prebuilt.nix {
177 # Not included at top-level
178 self = pythonInterpreters.pypy27_prebuilt;
179 sourceVersion = {
180 major = "7";
181 minor = "3";
182 patch = "1";
183 };
184 sha256 = "18xc5kwidj5hjwbr0w8v1nfpg5l4lk01z8cn804zfyyz8xjqhx5y"; # linux64
185 pythonVersion = "2.7";
186 inherit passthruFun;
187 };
188
189 pypy36_prebuilt = callPackage ./pypy/prebuilt.nix {
190 # Not included at top-level
191 self = pythonInterpreters.pypy36_prebuilt;
192 sourceVersion = {
193 major = "7";
194 minor = "3";
195 patch = "1";
196 };
197 sha256 = "04nv0mkalaliphbjw7y0pmb372bxwjzwmcsqkf9kwsik99kg2z7n"; # linux64
198 pythonVersion = "3.6";
199 inherit passthruFun;
200 };
201
202 graalpython37 = callPackage ./graalpython/default.nix {
203 self = pythonInterpreters.graalpython37;
204 inherit passthruFun;
205 };
206
207})