Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 nix-update-script, 6 pythonAtLeast, 7 pythonOlder, 8 stdenv, 9 10 # build-system 11 setuptools, 12 types-psutil, 13 types-setuptools, 14 15 # propagates 16 basedtyping, 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}: 31 32buildPythonPackage rec { 33 pname = "basedmypy"; 34 version = "2.10.0"; 35 pyproject = true; 36 37 disabled = pythonOlder "3.8"; 38 39 src = fetchFromGitHub { 40 owner = "KotlinIsland"; 41 repo = "basedmypy"; 42 tag = "v${version}"; 43 hash = "sha256-/43wVQoW/BbRD8j8Oypq5yz79ZTyAkLD4T8/aUg/QT8="; 44 }; 45 46 postPatch = '' 47 substituteInPlace \ 48 pyproject.toml \ 49 --replace-warn 'types-setuptools==' 'types-setuptools>=' 50 ''; 51 52 build-system = [ 53 basedtyping 54 mypy-extensions 55 types-psutil 56 types-setuptools 57 typing-extensions 58 ] 59 ++ lib.optionals (pythonOlder "3.11") [ tomli ]; 60 61 dependencies = [ 62 basedtyping 63 mypy-extensions 64 typing-extensions 65 ] 66 ++ lib.optionals (pythonOlder "3.11") [ tomli ]; 67 68 optional-dependencies = { 69 dmypy = [ psutil ]; 70 reports = [ lxml ]; 71 }; 72 73 # Compile mypy with mypyc, which makes mypy about 4 times faster. The compiled 74 # version is also the default in the wheels on Pypi that include binaries. 75 # is64bit: unfortunately the build would exhaust all possible memory on i686-linux. 76 env.MYPY_USE_MYPYC = stdenv.buildPlatform.is64bit; 77 78 # when testing reduce optimisation level to reduce build time by 20% 79 env.MYPYC_OPT_LEVEL = 1; 80 81 pythonImportsCheck = [ 82 "mypy" 83 "mypy.api" 84 "mypy.fastparse" 85 "mypy.types" 86 "mypyc" 87 "mypyc.analysis" 88 ] 89 ++ lib.optionals (!stdenv.hostPlatform.isi686) [ 90 # ImportError: cannot import name 'map_instance_to_supertype' from partially initialized module 'mypy.maptype' (most likely due to a circular import) 91 "mypy.report" 92 ]; 93 94 nativeCheckInputs = [ 95 attrs 96 filelock 97 pytest-xdist 98 pytestCheckHook 99 setuptools 100 tomli 101 ] 102 ++ lib.flatten (lib.attrValues optional-dependencies); 103 104 disabledTests = lib.optionals (pythonAtLeast "3.12") [ 105 # cannot find distutils, and distutils cannot find types 106 # https://github.com/NixOS/nixpkgs/pull/364818#discussion_r1895715378 107 "test_c_unit_test" 108 ]; 109 110 disabledTestPaths = [ 111 # fails to find typing_extensions 112 "mypy/test/testcmdline.py" 113 "mypy/test/testdaemon.py" 114 # fails to find setuptools 115 "mypyc/test/test_commandline.py" 116 # fails to find hatchling 117 "mypy/test/testpep561.py" 118 ] 119 ++ lib.optionals stdenv.hostPlatform.isi686 [ 120 # https://github.com/python/mypy/issues/15221 121 "mypyc/test/test_run.py" 122 ]; 123 124 passthru.updateScript = nix-update-script { }; 125 126 meta = { 127 description = "Based Python static type checker with baseline, sane default settings and based typing features"; 128 homepage = "https://kotlinisland.github.io/basedmypy/"; 129 changelog = "https://github.com/KotlinIsland/basedmypy/blob/${src.tag}/CHANGELOG.md"; 130 license = lib.licenses.mit; 131 mainProgram = "mypy"; 132 maintainers = with lib.maintainers; [ perchun ]; 133 }; 134}