at 25.11-pre 3.2 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 gitUpdater, 7 pythonAtLeast, 8 pythonOlder, 9 10 # build-system 11 setuptools, 12 types-psutil, 13 types-setuptools, 14 wheel, 15 16 # propagates 17 mypy-extensions, 18 tomli, 19 typing-extensions, 20 21 # optionals 22 lxml, 23 psutil, 24 25 # tests 26 attrs, 27 filelock, 28 pytest-xdist, 29 pytestCheckHook, 30 nixosTests, 31}: 32 33buildPythonPackage rec { 34 pname = "mypy"; 35 version = "1.15.0"; 36 pyproject = true; 37 38 disabled = pythonOlder "3.8"; 39 40 src = fetchFromGitHub { 41 owner = "python"; 42 repo = "mypy"; 43 tag = "v${version}"; 44 hash = "sha256-y67kt5i8mT9TcSbUGwnNuTAeqjy9apvWIbA2QD96LS4="; 45 }; 46 47 passthru.updateScript = gitUpdater { 48 rev-prefix = "v"; 49 }; 50 51 build-system = [ 52 mypy-extensions 53 setuptools 54 types-psutil 55 types-setuptools 56 typing-extensions 57 wheel 58 ] ++ lib.optionals (pythonOlder "3.11") [ tomli ]; 59 60 dependencies = [ 61 mypy-extensions 62 typing-extensions 63 ] ++ lib.optionals (pythonOlder "3.11") [ tomli ]; 64 65 optional-dependencies = { 66 dmypy = [ psutil ]; 67 reports = [ lxml ]; 68 }; 69 70 # Compile mypy with mypyc, which makes mypy about 4 times faster. The compiled 71 # version is also the default in the wheels on Pypi that include binaries. 72 # is64bit: unfortunately the build would exhaust all possible memory on i686-linux. 73 env.MYPY_USE_MYPYC = stdenv.buildPlatform.is64bit; 74 75 # when testing reduce optimisation level to reduce build time by 20% 76 env.MYPYC_OPT_LEVEL = 1; 77 78 pythonImportsCheck = 79 [ 80 "mypy" 81 "mypy.api" 82 "mypy.fastparse" 83 "mypy.types" 84 "mypyc" 85 "mypyc.analysis" 86 ] 87 ++ lib.optionals (!stdenv.hostPlatform.isi686) [ 88 # ImportError: cannot import name 'map_instance_to_supertype' from partially initialized module 'mypy.maptype' (most likely due to a circular import) 89 "mypy.report" 90 ]; 91 92 nativeCheckInputs = [ 93 attrs 94 filelock 95 pytest-xdist 96 pytestCheckHook 97 setuptools 98 tomli 99 ] ++ lib.flatten (lib.attrValues optional-dependencies); 100 101 disabledTests = 102 [ 103 # fails with typing-extensions>=4.10 104 # https://github.com/python/mypy/issues/17005 105 "test_runtime_typing_objects" 106 ] 107 ++ lib.optionals (pythonAtLeast "3.12") [ 108 # requires distutils 109 "test_c_unit_test" 110 ]; 111 112 disabledTestPaths = 113 [ 114 # fails to find tyoing_extensions 115 "mypy/test/testcmdline.py" 116 "mypy/test/testdaemon.py" 117 # fails to find setuptools 118 "mypyc/test/test_commandline.py" 119 # fails to find hatchling 120 "mypy/test/testpep561.py" 121 ] 122 ++ lib.optionals stdenv.hostPlatform.isi686 [ 123 # https://github.com/python/mypy/issues/15221 124 "mypyc/test/test_run.py" 125 ]; 126 127 passthru.tests = { 128 # Failing typing checks on the test-driver result in channel blockers. 129 inherit (nixosTests) nixos-test-driver; 130 }; 131 132 meta = { 133 description = "Optional static typing for Python"; 134 homepage = "https://www.mypy-lang.org"; 135 changelog = "https://github.com/python/mypy/blob/${src.rev}/CHANGELOG.md"; 136 license = lib.licenses.mit; 137 mainProgram = "mypy"; 138 maintainers = with lib.maintainers; [ lnl7 ]; 139 }; 140}