1{ lib
2, stdenv
3, autopep8
4, buildPythonPackage
5, docstring-to-markdown
6, fetchFromGitHub
7, flake8
8, flaky
9, jedi
10, matplotlib
11, mccabe
12, numpy
13, pandas
14, pluggy
15, pycodestyle
16, pydocstyle
17, pyflakes
18, pylint
19, pyqt5
20, pytestCheckHook
21, python-lsp-jsonrpc
22, pythonOlder
23, rope
24, setuptools
25, setuptools-scm
26, ujson
27, websockets
28, whatthepatch
29, yapf
30}:
31
32buildPythonPackage rec {
33 pname = "python-lsp-server";
34 version = "1.6.0";
35 format = "pyproject";
36
37 disabled = pythonOlder "3.7";
38
39 src = fetchFromGitHub {
40 owner = "python-lsp";
41 repo = pname;
42 rev = "refs/tags/v${version}";
43 sha256 = "sha256-1LV8FcwQqUg+FIkrorBYlxMl4F1PkrrOWjD5M0JSp3Q=";
44 };
45
46 SETUPTOOLS_SCM_PRETEND_VERSION = version;
47
48 postPatch = ''
49 substituteInPlace pyproject.toml \
50 --replace "--cov-report html --cov-report term --junitxml=pytest.xml" "" \
51 --replace "--cov pylsp --cov test" "" \
52 --replace "autopep8>=1.6.0,<1.7.0" "autopep8" \
53 --replace "flake8>=5.0.0,<5.1.0" "flake8" \
54 --replace "mccabe>=0.7.0,<0.8.0" "mccabe" \
55 --replace "pycodestyle>=2.9.0,<2.10.0" "pycodestyle" \
56 --replace "pyflakes>=2.5.0,<2.6.0" "pyflakes"
57 '';
58
59 nativeBuildInputs = [
60 setuptools-scm
61 ];
62
63 propagatedBuildInputs = [
64 docstring-to-markdown
65 jedi
66 pluggy
67 python-lsp-jsonrpc
68 setuptools # `pkg_resources`imported in pylsp/config/config.py
69 ujson
70 ];
71
72 passthru.optional-dependencies = {
73 all = [
74 autopep8
75 flake8
76 mccabe
77 pycodestyle
78 pydocstyle
79 pyflakes
80 pylint
81 rope
82 whatthepatch
83 yapf
84 ];
85 autopep8 = [
86 autopep8
87 ];
88 flake8 = [
89 flake8
90 ];
91 mccabe = [
92 mccabe
93 ];
94 pycodestyle = [
95 pycodestyle
96 ];
97 pydocstyle = [
98 pydocstyle
99 ];
100 pyflakes = [
101 pyflakes
102 ];
103 pylint = [
104 pylint
105 ];
106 rope = [
107 rope
108 ];
109 yapf = [
110 whatthepatch
111 yapf
112 ];
113 websockets = [
114 websockets
115 ];
116 };
117
118 checkInputs = [
119 flaky
120 matplotlib
121 numpy
122 pandas
123 pytestCheckHook
124 ] ++ passthru.optional-dependencies.all
125 # pyqt5 is broken on aarch64-darwin
126 ++ lib.optionals (!stdenv.isDarwin || !stdenv.isAarch64) [
127 pyqt5
128 ];
129
130 disabledTests = [
131 # https://github.com/python-lsp/python-lsp-server/issues/243
132 "test_numpy_completions"
133 "test_workspace_loads_pycodestyle_config"
134 ] ++ lib.optional (stdenv.isDarwin && stdenv.isAarch64) [
135 # pyqt5 is broken on aarch64-darwin
136 "test_pyqt_completion"
137 ];
138
139 preCheck = ''
140 export HOME=$(mktemp -d);
141 '';
142
143 pythonImportsCheck = [
144 "pylsp"
145 "pylsp.python_lsp"
146 ];
147
148 meta = with lib; {
149 description = "Python implementation of the Language Server Protocol";
150 homepage = "https://github.com/python-lsp/python-lsp-server";
151 license = licenses.mit;
152 maintainers = with maintainers; [ fab ];
153 };
154}