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