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