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