Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib
2, stdenv
3, fetchFromGitHub
4, attrs
5, buildPythonPackage
6, filelock
7, lxml
8, mypy-extensions
9, psutil
10, py
11, pytest-forked
12, pytest-xdist
13, pytestCheckHook
14, python
15, pythonOlder
16, setuptools
17, six
18, typed-ast
19, typing-extensions
20, tomli
21, types-setuptools
22, types-typed-ast
23, types-psutil
24, virtualenv
25}:
26
27buildPythonPackage rec {
28 pname = "mypy";
29 version = "0.991";
30 format = "pyproject";
31 disabled = pythonOlder "3.7";
32
33 src = fetchFromGitHub {
34 owner = "python";
35 repo = "mypy";
36 rev = "refs/tags/v${version}";
37 hash = "sha256-ljnMlQUlz4oiZqlqOlqJOumrP6wKLDGiDtT3Y5OEQog=";
38 };
39
40 nativeBuildInputs = [
41 setuptools
42 types-typed-ast
43 types-setuptools
44 types-psutil
45 ];
46
47 propagatedBuildInputs = [
48 mypy-extensions
49 typing-extensions
50 ] ++ lib.optionals (pythonOlder "3.11") [
51 tomli
52 ] ++ lib.optionals (pythonOlder "3.8") [
53 typed-ast
54 ];
55
56 passthru.optional-dependencies = {
57 dmypy = [ psutil ];
58 reports = [ lxml ];
59 };
60
61 # TODO: enable tests
62 doCheck = false;
63
64 pythonImportsCheck = [
65 "mypy"
66 "mypy.api"
67 "mypy.fastparse"
68 "mypy.types"
69 "mypyc"
70 "mypyc.analysis"
71 ] ++ lib.optionals (!stdenv.hostPlatform.isi686) [
72 # ImportError: cannot import name 'map_instance_to_supertype' from partially initialized module 'mypy.maptype' (most likely due to a circular import)
73 "mypy.report"
74 ];
75
76 # Compile mypy with mypyc, which makes mypy about 4 times faster. The compiled
77 # version is also the default in the wheels on Pypi that include binaries.
78 # is64bit: unfortunately the build would exhaust all possible memory on i686-linux.
79 MYPY_USE_MYPYC = stdenv.buildPlatform.is64bit;
80
81 # when testing reduce optimisation level to drastically reduce build time
82 MYPYC_OPT_LEVEL = 1;
83
84 meta = with lib; {
85 description = "Optional static typing for Python";
86 homepage = "http://www.mypy-lang.org";
87 license = licenses.mit;
88 maintainers = with maintainers; [ martingms lnl7 SuperSandro2000 ];
89 };
90}