nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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 , pythonOnBuildForBuild
18 , pythonOnBuildForHost
19 , pythonOnBuildForTarget
20 , pythonOnHostForHost
21 , pythonOnTargetForTarget
22 , self # is pythonOnHostForTarget
23 }: let
24 pythonPackages = callPackage
25 ({ pkgs, stdenv, python, overrides }: let
26 pythonPackagesFun = import ../../../top-level/python-packages.nix {
27 inherit stdenv pkgs lib;
28 python = self;
29 };
30 otherSplices = {
31 selfBuildBuild = pythonOnBuildForBuild.pkgs;
32 selfBuildHost = pythonOnBuildForHost.pkgs;
33 selfBuildTarget = pythonOnBuildForTarget.pkgs;
34 selfHostHost = pythonOnHostForHost.pkgs;
35 selfTargetTarget = pythonOnTargetForTarget.pkgs or {}; # There is no Python TargetTarget.
36 };
37 keep = self: {
38 # TODO maybe only define these here so nothing is needed to be kept in sync.
39 inherit (self)
40 isPy27 isPy35 isPy36 isPy37 isPy38 isPy39 isPy310 isPy3k isPyPy pythonAtLeast pythonOlder
41 python bootstrapped-pip buildPythonPackage buildPythonApplication
42 fetchPypi
43 hasPythonModule requiredPythonModules makePythonPath disabledIf
44 toPythonModule toPythonApplication
45 buildSetupcfg
46
47 condaInstallHook
48 condaUnpackHook
49 eggUnpackHook
50 eggBuildHook
51 eggInstallHook
52 flitBuildHook
53 pipBuildHook
54 pipInstallHook
55 pytestCheckHook
56 pythonCatchConflictsHook
57 pythonImportsCheckHook
58 pythonNamespacesHook
59 pythonRecompileBytecodeHook
60 pythonRemoveBinBytecodeHook
61 pythonRemoveTestsDirHook
62 setuptoolsBuildHook
63 setuptoolsCheckHook
64 venvShellHook
65 wheelUnpackHook
66
67 wrapPython
68
69 pythonPackages
70
71 recursivePthLoader
72 ;
73 };
74 extra = _: {};
75 optionalExtensions = cond: as: if cond then as else [];
76 python2Extension = import ../../../top-level/python2-packages.nix;
77 extensions = lib.composeManyExtensions ((optionalExtensions (!self.isPy3k) [python2Extension]) ++ [ overrides ]);
78 aliases = self: super: lib.optionalAttrs config.allowAliases (import ../../../top-level/python-aliases.nix lib self super);
79 in lib.makeScopeWithSplicing
80 pkgs.splicePackages
81 pkgs.newScope
82 otherSplices
83 keep
84 extra
85 (lib.extends (lib.composeExtensions aliases extensions) pythonPackagesFun))
86 {
87 overrides = packageOverrides;
88 python = self;
89 };
90 in rec {
91 isPy27 = pythonVersion == "2.7";
92 isPy35 = pythonVersion == "3.5";
93 isPy36 = pythonVersion == "3.6";
94 isPy37 = pythonVersion == "3.7";
95 isPy38 = pythonVersion == "3.8";
96 isPy39 = pythonVersion == "3.9";
97 isPy310 = pythonVersion == "3.10";
98 isPy311 = pythonVersion == "3.11";
99 isPy2 = lib.strings.substring 0 1 pythonVersion == "2";
100 isPy3 = lib.strings.substring 0 1 pythonVersion == "3";
101 isPy3k = isPy3;
102 isPyPy = lib.hasInfix "pypy" interpreter;
103
104 buildEnv = callPackage ./wrapper.nix { python = self; inherit (pythonPackages) requiredPythonModules; };
105 withPackages = import ./with-packages.nix { inherit buildEnv pythonPackages;};
106 pkgs = pythonPackages;
107 interpreter = "${self}/bin/${executable}";
108 inherit executable implementation libPrefix pythonVersion sitePackages;
109 inherit sourceVersion;
110 pythonAtLeast = lib.versionAtLeast pythonVersion;
111 pythonOlder = lib.versionOlder pythonVersion;
112 inherit hasDistutilsCxxPatch;
113 # TODO: rename to pythonOnBuild
114 # Not done immediately because its likely used outside Nixpkgs.
115 pythonForBuild = pythonOnBuildForHost.override { inherit packageOverrides; self = pythonForBuild; };
116
117 tests = callPackage ./tests.nix {
118 python = self;
119 };
120 };
121
122 sources = {
123 python39 = {
124 sourceVersion = {
125 major = "3";
126 minor = "9";
127 patch = "12";
128 suffix = "";
129 };
130 sha256 = "sha256-LNlLIGcOQVnG2atX+R2/JVuX2MGhRR0cNfTsGWit+XE=";
131 };
132 python310 = {
133 sourceVersion = {
134 major = "3";
135 minor = "10";
136 patch = "4";
137 suffix = "";
138 };
139 sha256 = "sha256-gL+SX1cdpDazUhCIbPefbrX6XWxXExa3NWg0NFH3ehk=";
140 };
141 };
142
143in {
144
145 python27 = callPackage ./cpython/2.7 {
146 self = python27;
147 sourceVersion = {
148 major = "2";
149 minor = "7";
150 patch = "18";
151 suffix = "";
152 };
153 sha256 = "0hzgxl94hnflis0d6m4szjx0b52gah7wpmcg5g00q7am6xwhwb5n";
154 inherit (darwin) configd;
155 inherit passthruFun;
156 };
157
158 python37 = callPackage ./cpython {
159 self = python37;
160 sourceVersion = {
161 major = "3";
162 minor = "7";
163 patch = "13";
164 suffix = "";
165 };
166 sha256 = "sha256-mfEGJ134iZw+jLnXwBzmhsIC7ydZUzAUJxlGk95b74Q=";
167 inherit (darwin) configd;
168 inherit passthruFun;
169 };
170
171 python38 = callPackage ./cpython {
172 self = python38;
173 sourceVersion = {
174 major = "3";
175 minor = "8";
176 patch = "13";
177 suffix = "";
178 };
179 sha256 = "sha256-bzCQdwEgQKo5/o8MYduMD6HEUTZ2MpnTdcnldW8Jz1c=";
180 inherit (darwin) configd;
181 inherit passthruFun;
182 };
183
184 python39 = callPackage ./cpython ({
185 self = python39;
186 inherit (darwin) configd;
187 inherit passthruFun;
188 } // sources.python39);
189
190 python310 = callPackage ./cpython ({
191 self = python310;
192 inherit (darwin) configd;
193 inherit passthruFun;
194 } // sources.python310);
195
196 python311 = callPackage ./cpython {
197 self = python311;
198 sourceVersion = {
199 major = "3";
200 minor = "11";
201 patch = "0";
202 suffix = "a7";
203 };
204 sha256 = "sha256-t8Vt10wvRy1Ja1qNNWvWrZ75sD8mKIwyN9P/aYqwPXQ=";
205 inherit (darwin) configd;
206 inherit passthruFun;
207 };
208
209 # Minimal versions of Python (built without optional dependencies)
210 python3Minimal = (callPackage ./cpython ({
211 self = python3Minimal;
212 inherit passthruFun;
213 pythonAttr = "python3Minimal";
214 # strip down that python version as much as possible
215 openssl = null;
216 readline = null;
217 ncurses = null;
218 gdbm = null;
219 sqlite = null;
220 configd = null;
221 tzdata = null;
222 libffi = pkgs.libffiBoot; # without test suite
223 stripConfig = true;
224 stripIdlelib = true;
225 stripTests = true;
226 stripTkinter = true;
227 rebuildBytecode = false;
228 stripBytecode = true;
229 includeSiteCustomize = false;
230 enableOptimizations = false;
231 enableLTO = false;
232 mimetypesSupport = false;
233 } // sources.python39)).overrideAttrs(old: {
234 pname = "python3-minimal";
235 meta = old.meta // {
236 maintainers = [];
237 };
238 });
239
240 pypy27 = callPackage ./pypy {
241 self = pypy27;
242 sourceVersion = {
243 major = "7";
244 minor = "3";
245 patch = "5";
246 };
247 sha256 = "sha256-wERP2YcwWMHA2Z4TqTTpIoXLBZksmWi/Ujwyv5vsCp0=";
248 pythonVersion = "2.7";
249 db = db.override { dbmSupport = !stdenv.isDarwin; };
250 python = python27;
251 inherit passthruFun;
252 inherit (darwin) libunwind;
253 inherit (darwin.apple_sdk.frameworks) Security;
254 };
255
256 pypy38 = callPackage ./pypy {
257 self = pypy38;
258 sourceVersion = {
259 major = "7";
260 minor = "3";
261 patch = "7";
262 };
263 sha256 = "sha256-Ia4zn09QFtbKcwAwXz47VUNzg1yzw5qQQf4w5oEcgMY=";
264 pythonVersion = "3.8";
265 db = db.override { dbmSupport = !stdenv.isDarwin; };
266 python = python27;
267 inherit passthruFun;
268 inherit (darwin) libunwind;
269 inherit (darwin.apple_sdk.frameworks) Security;
270 };
271 pypy37 = pypy38.override {
272 self = pythonInterpreters.pypy37;
273 pythonVersion = "3.7";
274 sha256 = "sha256-LtAqyecQhZxBvILer7CGGXkruaJ+6qFnbHQe3t0hTdc=";
275 };
276
277 pypy27_prebuilt = callPackage ./pypy/prebuilt_2_7.nix {
278 # Not included at top-level
279 self = pythonInterpreters.pypy27_prebuilt;
280 sourceVersion = {
281 major = "7";
282 minor = "3";
283 patch = "8";
284 };
285 sha256 = "0h493q0lhpz035afi4g09f4mz5a72vqx4sa7qcry5z4zagxq8bhz"; # linux64
286 pythonVersion = "2.7";
287 inherit passthruFun;
288 };
289
290 pypy38_prebuilt = callPackage ./pypy/prebuilt.nix {
291 # Not included at top-level
292 self = pythonInterpreters.pypy38_prebuilt;
293 sourceVersion = {
294 major = "7";
295 minor = "3";
296 patch = "7";
297 };
298 sha256 = "sha256-Xe43x8PLixYAKPveOlkBxoBD36VFoWeUUCuJfUvEDX4="; # linux64
299 pythonVersion = "3.8";
300 inherit passthruFun;
301 };
302
303 rustpython = callPackage ./rustpython/default.nix {
304 inherit (darwin.apple_sdk.frameworks) SystemConfiguration;
305 };
306
307})