nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at haskell-updates 504 lines 16 kB view raw
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 python = python.interpreter; 142 }; 143 } ./pypa-install-hook.sh 144 ) 145 { 146 inherit (pythonOnBuildForHost.pkgs) installer; 147 }; 148 149 pytestCheckHook = callPackage ( 150 { 151 makePythonHook, 152 pytest, 153 # For package tests 154 testers, 155 objprint, 156 }: 157 makePythonHook { 158 name = "pytest-check-hook"; 159 propagatedBuildInputs = [ pytest ]; 160 substitutions = { 161 inherit pythonCheckInterpreter; 162 }; 163 passthru = { 164 tests = { 165 basic = objprint.overridePythonAttrs (previousPythonAttrs: { 166 pname = "test-pytestCheckHook-basic-${previousPythonAttrs.pname}"; 167 }); 168 disabledTests = objprint.overridePythonAttrs (previousPythonAttrs: { 169 pname = "test-pytestCheckHook-disabledTests-${previousPythonAttrs.pname}"; 170 disabledTests = [ 171 "test_print" 172 ] 173 ++ previousPythonAttrs.disabledTests or [ ]; 174 }); 175 disabledTests-expression = objprint.overridePythonAttrs (previousPythonAttrs: { 176 __structuredAttrs = true; 177 pname = "test-pytestCheckHook-disabledTests-expression-${previousPythonAttrs.pname}"; 178 disabledTests = [ 179 "TestBasic and test_print" 180 "test_str" 181 ] 182 ++ previousPythonAttrs.disabledTests or [ ]; 183 }); 184 disabledTestPaths = objprint.overridePythonAttrs (previousPythonAttrs: { 185 pname = "test-pytestCheckHook-disabledTestPaths-${previousPythonAttrs.pname}"; 186 disabledTestPaths = [ 187 "tests/test_basic.py" 188 ] 189 ++ previousPythonAttrs.disabledTestPaths or [ ]; 190 }); 191 disabledTestPaths-nonexistent = testers.testBuildFailure ( 192 objprint.overridePythonAttrs (previousPythonAttrs: { 193 pname = "test-pytestCheckHook-disabledTestPaths-nonexistent-${previousPythonAttrs.pname}"; 194 disabledTestPaths = [ 195 "tests/test_foo.py" 196 ] 197 ++ previousPythonAttrs.disabledTestPaths or [ ]; 198 }) 199 ); 200 disabledTestPaths-item = objprint.overridePythonAttrs (previousPythonAttrs: { 201 pname = "test-pytestCheckHook-disabledTestPaths-item-${previousPythonAttrs.pname}"; 202 disabledTestPaths = [ 203 "tests/test_basic.py::TestBasic" 204 ] 205 ++ previousPythonAttrs.disabledTestPaths or [ ]; 206 }); 207 disabledTestPaths-glob = objprint.overridePythonAttrs (previousPythonAttrs: { 208 pname = "test-pytestCheckHook-disabledTestPaths-glob-${previousPythonAttrs.pname}"; 209 disabledTestPaths = [ 210 "tests/test_obj*.py" 211 ] 212 ++ previousPythonAttrs.disabledTestPaths or [ ]; 213 }); 214 disabledTestPaths-glob-nonexistent = testers.testBuildFailure ( 215 objprint.overridePythonAttrs (previousPythonAttrs: { 216 pname = "test-pytestCheckHook-disabledTestPaths-glob-nonexistent-${previousPythonAttrs.pname}"; 217 disabledTestPaths = [ 218 "tests/test_foo*.py" 219 ] 220 ++ previousPythonAttrs.disabledTestPaths or [ ]; 221 }) 222 ); 223 enabledTests = objprint.overridePythonAttrs (previousPythonAttrs: { 224 pname = "test-pytestCheckHook-enabledTests-${previousPythonAttrs.pname}"; 225 enabledTests = [ 226 "TestBasic" 227 ] 228 ++ previousPythonAttrs.disabledTests or [ ]; 229 }); 230 enabledTests-expression = objprint.overridePythonAttrs (previousPythonAttrs: { 231 __structuredAttrs = true; 232 pname = "test-pytestCheckHook-enabledTests-expression-${previousPythonAttrs.pname}"; 233 enabledTests = [ 234 "TestBasic and test_print" 235 "test_str" 236 ] 237 ++ previousPythonAttrs.disabledTests or [ ]; 238 }); 239 enabledTests-disabledTests = objprint.overridePythonAttrs (previousPythonAttrs: { 240 pname = "test-pytestCheckHook-enabledTests-disabledTests-${previousPythonAttrs.pname}"; 241 enabledTests = [ 242 "TestBasic" 243 ] 244 ++ previousPythonAttrs.disabledTests or [ ]; 245 disabledTests = [ 246 "test_print" 247 ] 248 ++ previousPythonAttrs.disabledTests or [ ]; 249 }); 250 enabledTestPaths = objprint.overridePythonAttrs (previousPythonAttrs: { 251 pname = "test-pytestCheckHook-enabledTestPaths-${previousPythonAttrs.pname}"; 252 enabledTestPaths = [ 253 "tests/test_basic.py" 254 ] 255 ++ previousPythonAttrs.enabledTestPaths or [ ]; 256 }); 257 enabledTestPaths-nonexistent = testers.testBuildFailure ( 258 objprint.overridePythonAttrs (previousPythonAttrs: { 259 pname = "test-pytestCheckHook-enabledTestPaths-nonexistent-${previousPythonAttrs.pname}"; 260 enabledTestPaths = [ 261 "tests/test_foo.py" 262 ] 263 ++ previousPythonAttrs.enabledTestPaths or [ ]; 264 }) 265 ); 266 enabledTestPaths-dir = objprint.overridePythonAttrs (previousPythonAttrs: { 267 pname = "test-pytestCheckHook-enabledTestPaths-dir-${previousPythonAttrs.pname}"; 268 enabledTestPaths = [ 269 "tests" 270 ] 271 ++ previousPythonAttrs.enabledTestPaths or [ ]; 272 }); 273 enabledTestPaths-dir-disabledTestPaths = objprint.overridePythonAttrs (previousPythonAttrs: { 274 pname = "test-pytestCheckHook-enabledTestPaths-dir-disabledTestPaths-${previousPythonAttrs.pname}"; 275 enabledTestPaths = [ 276 "tests" 277 ] 278 ++ previousPythonAttrs.enabledTestPaths or [ ]; 279 disabledTestPaths = [ 280 "tests/test_basic.py" 281 ] 282 ++ previousPythonAttrs.disabledTestPaths or [ ]; 283 }); 284 enabledTestPaths-glob = objprint.overridePythonAttrs (previousPythonAttrs: { 285 pname = "test-pytestCheckHook-enabledTestPaths-glob-${previousPythonAttrs.pname}"; 286 enabledTestPaths = [ 287 "tests/test_obj*.py" 288 ] 289 ++ previousPythonAttrs.enabledTestPaths or [ ]; 290 }); 291 enabledTestPaths-glob-nonexistent = testers.testBuildFailure ( 292 objprint.overridePythonAttrs (previousPythonAttrs: { 293 pname = "test-pytestCheckHook-enabledTestPaths-glob-nonexistent-${previousPythonAttrs.pname}"; 294 enabledTestPaths = [ 295 "tests/test_foo*.py" 296 ] 297 ++ previousPythonAttrs.enabledTestPaths or [ ]; 298 }) 299 ); 300 enabledTestPaths-item = objprint.overridePythonAttrs (previousPythonAttrs: { 301 pname = "test-pytestCheckHook-enabledTestPaths-item-${previousPythonAttrs.pname}"; 302 enabledTestPaths = [ 303 "tests/test_basic.py::TestBasic" 304 ] 305 ++ previousPythonAttrs.enabledTestPaths or [ ]; 306 }); 307 }; 308 }; 309 } ./pytest-check-hook.sh 310 ) { }; 311 312 pythonCatchConflictsHook = callPackage ( 313 { makePythonHook, setuptools }: 314 makePythonHook { 315 name = "python-catch-conflicts-hook"; 316 substitutions = 317 let 318 useLegacyHook = lib.versionOlder python.pythonVersion "3"; 319 in 320 { 321 inherit pythonInterpreter pythonSitePackages; 322 catchConflicts = 323 if useLegacyHook then 324 ../catch_conflicts/catch_conflicts_py2.py 325 else 326 ../catch_conflicts/catch_conflicts.py; 327 } 328 // lib.optionalAttrs useLegacyHook { 329 inherit setuptools; 330 }; 331 passthru.tests = import ./python-catch-conflicts-hook-tests.nix { 332 inherit pythonOnBuildForHost runCommand; 333 inherit lib; 334 inherit (pkgs) coreutils gnugrep writeShellScript; 335 }; 336 } ./python-catch-conflicts-hook.sh 337 ) { }; 338 339 pythonImportsCheckHook = callPackage ( 340 { makePythonHook }: 341 makePythonHook { 342 name = "python-imports-check-hook.sh"; 343 substitutions = { 344 inherit pythonCheckInterpreter pythonSitePackages; 345 }; 346 } ./python-imports-check-hook.sh 347 ) { }; 348 349 pythonNamespacesHook = callPackage ( 350 { makePythonHook, buildPackages }: 351 makePythonHook { 352 name = "python-namespaces-hook.sh"; 353 substitutions = { 354 inherit pythonSitePackages; 355 inherit (buildPackages) findutils; 356 }; 357 } ./python-namespaces-hook.sh 358 ) { }; 359 360 pythonOutputDistHook = callPackage ( 361 { makePythonHook }: 362 makePythonHook { 363 name = "python-output-dist-hook"; 364 } ./python-output-dist-hook.sh 365 ) { }; 366 367 pythonRecompileBytecodeHook = callPackage ( 368 { makePythonHook }: 369 makePythonHook { 370 name = "python-recompile-bytecode-hook"; 371 substitutions = { 372 inherit pythonInterpreter pythonSitePackages; 373 compileArgs = lib.concatStringsSep " " ( 374 [ 375 "-q" 376 "-f" 377 "-i -" 378 ] 379 ++ lib.optionals isPy3k [ "-j $NIX_BUILD_CORES" ] 380 ); 381 bytecodeName = if isPy3k then "__pycache__" else "*.pyc"; 382 }; 383 } ./python-recompile-bytecode-hook.sh 384 ) { }; 385 386 pythonRelaxDepsHook = callPackage ( 387 { makePythonHook, wheel }: 388 makePythonHook { 389 name = "python-relax-deps-hook"; 390 substitutions = { 391 inherit pythonInterpreter pythonSitePackages wheel; 392 }; 393 } ./python-relax-deps-hook.sh 394 ) { }; 395 396 pythonRemoveBinBytecodeHook = callPackage ( 397 { makePythonHook }: 398 makePythonHook { 399 name = "python-remove-bin-bytecode-hook"; 400 } ./python-remove-bin-bytecode-hook.sh 401 ) { }; 402 403 pythonRemoveTestsDirHook = callPackage ( 404 { makePythonHook }: 405 makePythonHook { 406 name = "python-remove-tests-dir-hook"; 407 substitutions = { 408 inherit pythonSitePackages; 409 }; 410 } ./python-remove-tests-dir-hook.sh 411 ) { }; 412 413 pythonRuntimeDepsCheckHook = callPackage ( 414 { makePythonHook, packaging }: 415 makePythonHook { 416 name = "python-runtime-deps-check-hook.sh"; 417 propagatedBuildInputs = [ packaging ]; 418 substitutions = { 419 inherit pythonInterpreter pythonSitePackages; 420 hook = ./python-runtime-deps-check-hook.py; 421 }; 422 } ./python-runtime-deps-check-hook.sh 423 ) { }; 424 425 setuptoolsBuildHook = callPackage ( 426 { 427 makePythonHook, 428 setuptools, 429 wheel, 430 }: 431 makePythonHook { 432 name = "setuptools-build-hook"; 433 propagatedBuildInputs = [ 434 setuptools 435 wheel 436 ]; 437 substitutions = { 438 inherit pythonInterpreter setuppy; 439 # python2.pkgs.setuptools does not support parallelism 440 setuptools_has_parallel = setuptools != null && lib.versionAtLeast setuptools.version "69"; 441 }; 442 } ./setuptools-build-hook.sh 443 ) { }; 444 445 stestrCheckHook = callPackage ( 446 { makePythonHook }: 447 makePythonHook { 448 name = "stestr-check-hook"; 449 propagatedBuildInputs = [ stestr ]; 450 substitutions = { 451 inherit pythonCheckInterpreter; 452 }; 453 } ./stestr-check-hook.sh 454 ) { }; 455 456 unittestCheckHook = callPackage ( 457 { makePythonHook }: 458 makePythonHook { 459 name = "unittest-check-hook"; 460 substitutions = { 461 inherit pythonCheckInterpreter; 462 }; 463 } ./unittest-check-hook.sh 464 ) { }; 465 466 venvShellHook = disabledIf (!isPy3k) ( 467 callPackage ( 468 { makePythonHook, ensureNewerSourcesForZipFilesHook }: 469 makePythonHook { 470 name = "venv-shell-hook"; 471 propagatedBuildInputs = [ ensureNewerSourcesForZipFilesHook ]; 472 substitutions = { 473 inherit pythonInterpreter; 474 }; 475 } ./venv-shell-hook.sh 476 ) { } 477 ); 478 479 wheelUnpackHook = callPackage ( 480 { makePythonHook, wheel }: 481 makePythonHook { 482 name = "wheel-unpack-hook.sh"; 483 propagatedBuildInputs = [ wheel ]; 484 } ./wheel-unpack-hook.sh 485 ) { }; 486 487 wrapPython = callPackage ../wrap-python.nix { 488 inherit (pkgs.buildPackages) makeWrapper; 489 }; 490 491 sphinxHook = callPackage ( 492 { makePythonHook, installShellFiles }: 493 makePythonHook { 494 name = "python${python.pythonVersion}-sphinx-hook"; 495 propagatedBuildInputs = [ 496 pythonOnBuildForHost.pkgs.sphinx 497 installShellFiles 498 ]; 499 substitutions = { 500 sphinxBuild = "${pythonOnBuildForHost.pkgs.sphinx}/bin/sphinx-build"; 501 }; 502 } ./sphinx-hook.sh 503 ) { }; 504}