nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, fetchFromGitHub
4, fetchpatch
5, buildPythonPackage
6, mypy-extensions
7, python
8, pythonOlder
9, typed-ast
10, typing-extensions
11, tomli
12, types-typed-ast
13}:
14
15buildPythonPackage rec {
16 pname = "mypy";
17 version = "0.941";
18 disabled = pythonOlder "3.6";
19
20 src = fetchFromGitHub {
21 owner = "python";
22 repo = "mypy";
23 rev = "v${version}";
24 hash = "sha256-H2SWJA0WWyKV7/5miFawv4JRXu/J7H6Wer1eBL+Tru0=";
25 };
26
27 patches = [
28 # FIXME: Remove patch after upstream has decided the proper solution.
29 # https://github.com/python/mypy/pull/11143
30 (fetchpatch {
31 url = "https://github.com/python/mypy/commit/e7869f05751561958b946b562093397027f6d5fa.patch";
32 hash = "sha256-waIZ+m3tfvYE4HJ8kL6rN/C4fMjvLEe9UoPbt9mHWIM=";
33 })
34 ];
35
36 buildInputs = [
37 types-typed-ast
38 ];
39
40 propagatedBuildInputs = [
41 mypy-extensions
42 tomli
43 typed-ast
44 typing-extensions
45 ];
46
47 # Tests not included in pip package.
48 doCheck = false;
49
50 pythonImportsCheck = [
51 "mypy"
52 "mypy.api"
53 "mypy.fastparse"
54 "mypy.report"
55 "mypy.types"
56 "mypyc"
57 "mypyc.analysis"
58 ];
59
60 # Compile mypy with mypyc, which makes mypy about 4 times faster. The compiled
61 # version is also the default in the wheels on Pypi that include binaries.
62 # is64bit: unfortunately the build would exhaust all possible memory on i686-linux.
63 MYPY_USE_MYPYC = stdenv.buildPlatform.is64bit;
64
65 # when testing reduce optimisation level to drastically reduce build time
66 MYPYC_OPT_LEVEL = 1;
67
68 meta = with lib; {
69 description = "Optional static typing for Python";
70 homepage = "http://www.mypy-lang.org";
71 license = licenses.mit;
72 maintainers = with maintainers; [ martingms lnl7 SuperSandro2000 ];
73 };
74}