nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1self: dontUse:
2with self;
3
4let
5 inherit (python) pythonOnBuildForHost;
6 inherit (pkgs) runCommand;
7 pythonInterpreter = pythonOnBuildForHost.interpreter;
8 pythonSitePackages = python.sitePackages;
9 pythonCheckInterpreter = python.interpreter;
10 setuppy = ../run_setup.py;
11in
12{
13 makePythonHook =
14 let
15 defaultArgs = {
16 passthru.provides.setupHook = true;
17 };
18 in
19 args: pkgs.makeSetupHook (lib.recursiveUpdate defaultArgs args);
20
21 condaInstallHook = callPackage (
22 {
23 makePythonHook,
24 gnutar,
25 lbzip2,
26 }:
27 makePythonHook {
28 name = "conda-install-hook";
29 propagatedBuildInputs = [
30 gnutar
31 lbzip2
32 ];
33 substitutions = {
34 inherit pythonSitePackages;
35 };
36 } ./conda-install-hook.sh
37 ) { };
38
39 condaUnpackHook = callPackage (
40 { makePythonHook }:
41 makePythonHook {
42 name = "conda-unpack-hook";
43 propagatedBuildInputs = [ ];
44 } ./conda-unpack-hook.sh
45 ) { };
46
47 eggBuildHook = callPackage (
48 { makePythonHook }:
49 makePythonHook {
50 name = "egg-build-hook.sh";
51 propagatedBuildInputs = [ ];
52 } ./egg-build-hook.sh
53 ) { };
54
55 eggInstallHook = callPackage (
56 { makePythonHook, setuptools }:
57 makePythonHook {
58 name = "egg-install-hook.sh";
59 propagatedBuildInputs = [ setuptools ];
60 substitutions = {
61 inherit pythonInterpreter pythonSitePackages;
62 };
63 } ./egg-install-hook.sh
64 ) { };
65
66 eggUnpackHook = callPackage (
67 { makePythonHook }:
68 makePythonHook {
69 name = "egg-unpack-hook.sh";
70 propagatedBuildInputs = [ ];
71 } ./egg-unpack-hook.sh
72 ) { };
73
74 pipBuildHook = callPackage (
75 {
76 makePythonHook,
77 pip,
78 wheel,
79 }:
80 makePythonHook {
81 name = "pip-build-hook.sh";
82 propagatedBuildInputs = [
83 pip
84 wheel
85 ];
86 substitutions = {
87 inherit pythonInterpreter pythonSitePackages;
88 };
89 } ./pip-build-hook.sh
90 ) { };
91
92 pypaBuildHook =
93 callPackage
94 (
95 {
96 makePythonHook,
97 build,
98 wheel,
99 }:
100 makePythonHook {
101 name = "pypa-build-hook.sh";
102 propagatedBuildInputs = [ wheel ];
103 substitutions = {
104 inherit build;
105 };
106 # A test to ensure that this hook never propagates any of its dependencies
107 # into the build environment.
108 # This prevents false positive alerts raised by catchConflictsHook.
109 # Such conflicts don't happen within the standard nixpkgs python package
110 # set, but in downstream projects that build packages depending on other
111 # versions of this hook's dependencies.
112 passthru.tests = callPackage ./pypa-build-hook-test.nix {
113 inherit pythonOnBuildForHost;
114 };
115 } ./pypa-build-hook.sh
116 )
117 {
118 inherit (pythonOnBuildForHost.pkgs) build;
119 };
120
121 pipInstallHook = callPackage (
122 { makePythonHook, pip }:
123 makePythonHook {
124 name = "pip-install-hook";
125 propagatedBuildInputs = [ pip ];
126 substitutions = {
127 inherit pythonInterpreter pythonSitePackages;
128 };
129 } ./pip-install-hook.sh
130 ) { };
131
132 pypaInstallHook =
133 callPackage
134 (
135 { makePythonHook, installer }:
136 makePythonHook {
137 name = "pypa-install-hook";
138 propagatedBuildInputs = [ installer ];
139 substitutions = {
140 inherit pythonInterpreter pythonSitePackages;
141 };
142 } ./pypa-install-hook.sh
143 )
144 {
145 inherit (pythonOnBuildForHost.pkgs) installer;
146 };
147
148 pytestCheckHook = callPackage (
149 {
150 makePythonHook,
151 pytest,
152 # For package tests
153 testers,
154 objprint,
155 }:
156 makePythonHook {
157 name = "pytest-check-hook";
158 propagatedBuildInputs = [ pytest ];
159 substitutions = {
160 inherit pythonCheckInterpreter;
161 };
162 passthru = {
163 tests = {
164 basic = objprint.overridePythonAttrs (previousPythonAttrs: {
165 pname = "test-pytestCheckHook-basic-${previousPythonAttrs.pname}";
166 });
167 disabledTests = objprint.overridePythonAttrs (previousPythonAttrs: {
168 pname = "test-pytestCheckHook-disabledTests-${previousPythonAttrs.pname}";
169 disabledTests = [
170 "test_print"
171 ] ++ previousPythonAttrs.disabledTests or [ ];
172 });
173 disabledTests-expression = objprint.overridePythonAttrs (previousPythonAttrs: {
174 __structuredAttrs = true;
175 pname = "test-pytestCheckHook-disabledTests-expression-${previousPythonAttrs.pname}";
176 disabledTests = [
177 "TestBasic and test_print"
178 "test_str"
179 ] ++ previousPythonAttrs.disabledTests or [ ];
180 });
181 disabledTestPaths = objprint.overridePythonAttrs (previousPythonAttrs: {
182 pname = "test-pytestCheckHook-disabledTestPaths-${previousPythonAttrs.pname}";
183 disabledTestPaths = [
184 "tests/test_basic.py"
185 ] ++ previousPythonAttrs.disabledTestPaths or [ ];
186 });
187 disabledTestPaths-nonexistent = testers.testBuildFailure (
188 objprint.overridePythonAttrs (previousPythonAttrs: {
189 pname = "test-pytestCheckHook-disabledTestPaths-nonexistent-${previousPythonAttrs.pname}";
190 disabledTestPaths = [
191 "tests/test_foo.py"
192 ] ++ previousPythonAttrs.disabledTestPaths or [ ];
193 })
194 );
195 disabledTestPaths-item = objprint.overridePythonAttrs (previousPythonAttrs: {
196 pname = "test-pytestCheckHook-disabledTestPaths-item-${previousPythonAttrs.pname}";
197 disabledTestPaths = [
198 "tests/test_basic.py::TestBasic"
199 ] ++ previousPythonAttrs.disabledTestPaths or [ ];
200 });
201 disabledTestPaths-glob = objprint.overridePythonAttrs (previousPythonAttrs: {
202 pname = "test-pytestCheckHook-disabledTestPaths-glob-${previousPythonAttrs.pname}";
203 disabledTestPaths = [
204 "tests/test_obj*.py"
205 ] ++ previousPythonAttrs.disabledTestPaths or [ ];
206 });
207 disabledTestPaths-glob-nonexistent = testers.testBuildFailure (
208 objprint.overridePythonAttrs (previousPythonAttrs: {
209 pname = "test-pytestCheckHook-disabledTestPaths-glob-nonexistent-${previousPythonAttrs.pname}";
210 disabledTestPaths = [
211 "tests/test_foo*.py"
212 ] ++ previousPythonAttrs.disabledTestPaths or [ ];
213 })
214 );
215 enabledTests = objprint.overridePythonAttrs (previousPythonAttrs: {
216 pname = "test-pytestCheckHook-enabledTests-${previousPythonAttrs.pname}";
217 enabledTests = [
218 "TestBasic"
219 ] ++ previousPythonAttrs.disabledTests or [ ];
220 });
221 enabledTests-expression = objprint.overridePythonAttrs (previousPythonAttrs: {
222 __structuredAttrs = true;
223 pname = "test-pytestCheckHook-enabledTests-expression-${previousPythonAttrs.pname}";
224 enabledTests = [
225 "TestBasic and test_print"
226 "test_str"
227 ] ++ previousPythonAttrs.disabledTests or [ ];
228 });
229 enabledTests-disabledTests = objprint.overridePythonAttrs (previousPythonAttrs: {
230 pname = "test-pytestCheckHook-enabledTests-disabledTests-${previousPythonAttrs.pname}";
231 enabledTests = [
232 "TestBasic"
233 ] ++ previousPythonAttrs.disabledTests or [ ];
234 disabledTests = [
235 "test_print"
236 ] ++ previousPythonAttrs.disabledTests or [ ];
237 });
238 enabledTestPaths = objprint.overridePythonAttrs (previousPythonAttrs: {
239 pname = "test-pytestCheckHook-enabledTestPaths-${previousPythonAttrs.pname}";
240 enabledTestPaths = [
241 "tests/test_basic.py"
242 ] ++ previousPythonAttrs.enabledTestPaths or [ ];
243 });
244 enabledTestPaths-nonexistent = testers.testBuildFailure (
245 objprint.overridePythonAttrs (previousPythonAttrs: {
246 pname = "test-pytestCheckHook-enabledTestPaths-nonexistent-${previousPythonAttrs.pname}";
247 enabledTestPaths = [
248 "tests/test_foo.py"
249 ] ++ previousPythonAttrs.enabledTestPaths or [ ];
250 })
251 );
252 enabledTestPaths-dir = objprint.overridePythonAttrs (previousPythonAttrs: {
253 pname = "test-pytestCheckHook-enabledTestPaths-dir-${previousPythonAttrs.pname}";
254 enabledTestPaths = [
255 "tests"
256 ] ++ previousPythonAttrs.enabledTestPaths or [ ];
257 });
258 enabledTestPaths-dir-disabledTestPaths = objprint.overridePythonAttrs (previousPythonAttrs: {
259 pname = "test-pytestCheckHook-enabledTestPaths-dir-disabledTestPaths-${previousPythonAttrs.pname}";
260 enabledTestPaths = [
261 "tests"
262 ] ++ previousPythonAttrs.enabledTestPaths or [ ];
263 disabledTestPaths = [
264 "tests/test_basic.py"
265 ] ++ previousPythonAttrs.disabledTestPaths or [ ];
266 });
267 enabledTestPaths-glob = objprint.overridePythonAttrs (previousPythonAttrs: {
268 pname = "test-pytestCheckHook-enabledTestPaths-glob-${previousPythonAttrs.pname}";
269 enabledTestPaths = [
270 "tests/test_obj*.py"
271 ] ++ previousPythonAttrs.enabledTestPaths or [ ];
272 });
273 enabledTestPaths-glob-nonexistent = testers.testBuildFailure (
274 objprint.overridePythonAttrs (previousPythonAttrs: {
275 pname = "test-pytestCheckHook-enabledTestPaths-glob-nonexistent-${previousPythonAttrs.pname}";
276 enabledTestPaths = [
277 "tests/test_foo*.py"
278 ] ++ previousPythonAttrs.enabledTestPaths or [ ];
279 })
280 );
281 enabledTestPaths-item = objprint.overridePythonAttrs (previousPythonAttrs: {
282 pname = "test-pytestCheckHook-enabledTestPaths-item-${previousPythonAttrs.pname}";
283 enabledTestPaths = [
284 "tests/test_basic.py::TestBasic"
285 ] ++ previousPythonAttrs.enabledTestPaths or [ ];
286 });
287 };
288 };
289 } ./pytest-check-hook.sh
290 ) { };
291
292 pythonCatchConflictsHook = callPackage (
293 { makePythonHook, setuptools }:
294 makePythonHook {
295 name = "python-catch-conflicts-hook";
296 substitutions =
297 let
298 useLegacyHook = lib.versionOlder python.pythonVersion "3";
299 in
300 {
301 inherit pythonInterpreter pythonSitePackages;
302 catchConflicts =
303 if useLegacyHook then
304 ../catch_conflicts/catch_conflicts_py2.py
305 else
306 ../catch_conflicts/catch_conflicts.py;
307 }
308 // lib.optionalAttrs useLegacyHook {
309 inherit setuptools;
310 };
311 passthru.tests = import ./python-catch-conflicts-hook-tests.nix {
312 inherit pythonOnBuildForHost runCommand;
313 inherit lib;
314 inherit (pkgs) coreutils gnugrep writeShellScript;
315 };
316 } ./python-catch-conflicts-hook.sh
317 ) { };
318
319 pythonImportsCheckHook = callPackage (
320 { makePythonHook }:
321 makePythonHook {
322 name = "python-imports-check-hook.sh";
323 substitutions = {
324 inherit pythonCheckInterpreter pythonSitePackages;
325 };
326 } ./python-imports-check-hook.sh
327 ) { };
328
329 pythonNamespacesHook = callPackage (
330 { makePythonHook, buildPackages }:
331 makePythonHook {
332 name = "python-namespaces-hook.sh";
333 substitutions = {
334 inherit pythonSitePackages;
335 inherit (buildPackages) findutils;
336 };
337 } ./python-namespaces-hook.sh
338 ) { };
339
340 pythonOutputDistHook = callPackage (
341 { makePythonHook }:
342 makePythonHook {
343 name = "python-output-dist-hook";
344 } ./python-output-dist-hook.sh
345 ) { };
346
347 pythonRecompileBytecodeHook = callPackage (
348 { makePythonHook }:
349 makePythonHook {
350 name = "python-recompile-bytecode-hook";
351 substitutions = {
352 inherit pythonInterpreter pythonSitePackages;
353 compileArgs = lib.concatStringsSep " " (
354 [
355 "-q"
356 "-f"
357 "-i -"
358 ]
359 ++ lib.optionals isPy3k [ "-j $NIX_BUILD_CORES" ]
360 );
361 bytecodeName = if isPy3k then "__pycache__" else "*.pyc";
362 };
363 } ./python-recompile-bytecode-hook.sh
364 ) { };
365
366 pythonRelaxDepsHook = callPackage (
367 { makePythonHook, wheel }:
368 makePythonHook {
369 name = "python-relax-deps-hook";
370 substitutions = {
371 inherit pythonInterpreter pythonSitePackages wheel;
372 };
373 } ./python-relax-deps-hook.sh
374 ) { };
375
376 pythonRemoveBinBytecodeHook = callPackage (
377 { makePythonHook }:
378 makePythonHook {
379 name = "python-remove-bin-bytecode-hook";
380 } ./python-remove-bin-bytecode-hook.sh
381 ) { };
382
383 pythonRemoveTestsDirHook = callPackage (
384 { makePythonHook }:
385 makePythonHook {
386 name = "python-remove-tests-dir-hook";
387 substitutions = {
388 inherit pythonSitePackages;
389 };
390 } ./python-remove-tests-dir-hook.sh
391 ) { };
392
393 pythonRuntimeDepsCheckHook = callPackage (
394 { makePythonHook, packaging }:
395 makePythonHook {
396 name = "python-runtime-deps-check-hook.sh";
397 propagatedBuildInputs = [ packaging ];
398 substitutions = {
399 inherit pythonInterpreter pythonSitePackages;
400 hook = ./python-runtime-deps-check-hook.py;
401 };
402 } ./python-runtime-deps-check-hook.sh
403 ) { };
404
405 setuptoolsBuildHook = callPackage (
406 {
407 makePythonHook,
408 setuptools,
409 wheel,
410 }:
411 makePythonHook {
412 name = "setuptools-build-hook";
413 propagatedBuildInputs = [
414 setuptools
415 wheel
416 ];
417 substitutions = {
418 inherit pythonInterpreter setuppy;
419 # python2.pkgs.setuptools does not support parallelism
420 setuptools_has_parallel = setuptools != null && lib.versionAtLeast setuptools.version "69";
421 };
422 } ./setuptools-build-hook.sh
423 ) { };
424
425 setuptoolsCheckHook = throw "The setuptoolsCheckHook has been removed, since the test command has been removed in setuptools 72.0";
426
427 setuptoolsRustBuildHook = callPackage (
428 { makePythonHook, setuptools-rust }:
429 makePythonHook {
430 name = "setuptools-rust-setup-hook";
431 propagatedBuildInputs = [ setuptools-rust ];
432 substitutions = {
433 pyLibDir = "${python}/lib/${python.libPrefix}";
434 cargoBuildTarget = stdenv.hostPlatform.rust.rustcTargetSpec;
435 cargoLinkerVar = stdenv.hostPlatform.rust.cargoEnvVarTarget;
436 targetLinker = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
437 };
438 } ./setuptools-rust-hook.sh
439 ) { };
440
441 unittestCheckHook = callPackage (
442 { makePythonHook }:
443 makePythonHook {
444 name = "unittest-check-hook";
445 substitutions = {
446 inherit pythonCheckInterpreter;
447 };
448 } ./unittest-check-hook.sh
449 ) { };
450
451 venvShellHook = disabledIf (!isPy3k) (
452 callPackage (
453 { makePythonHook, ensureNewerSourcesForZipFilesHook }:
454 makePythonHook {
455 name = "venv-shell-hook";
456 propagatedBuildInputs = [ ensureNewerSourcesForZipFilesHook ];
457 substitutions = {
458 inherit pythonInterpreter;
459 };
460 } ./venv-shell-hook.sh
461 ) { }
462 );
463
464 wheelUnpackHook = callPackage (
465 { makePythonHook, wheel }:
466 makePythonHook {
467 name = "wheel-unpack-hook.sh";
468 propagatedBuildInputs = [ wheel ];
469 } ./wheel-unpack-hook.sh
470 ) { };
471
472 wrapPython = callPackage ../wrap-python.nix {
473 inherit (pkgs.buildPackages) makeWrapper;
474 };
475
476 sphinxHook = callPackage (
477 { makePythonHook, installShellFiles }:
478 makePythonHook {
479 name = "python${python.pythonVersion}-sphinx-hook";
480 propagatedBuildInputs = [
481 pythonOnBuildForHost.pkgs.sphinx
482 installShellFiles
483 ];
484 substitutions = {
485 sphinxBuild = "${pythonOnBuildForHost.pkgs.sphinx}/bin/sphinx-build";
486 };
487 } ./sphinx-hook.sh
488 ) { };
489}