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