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