1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pythonOlder,
6
7 # build-system
8 setuptools-scm,
9
10 # dependencies
11 docstring-to-markdown,
12 jedi,
13 pluggy,
14 python-lsp-jsonrpc,
15 setuptools,
16 ujson,
17 importlib-metadata,
18
19 # optional-dependencies
20 autopep8,
21 flake8,
22 mccabe,
23 pycodestyle,
24 pydocstyle,
25 pyflakes,
26 pylint,
27 rope,
28 toml,
29 whatthepatch,
30 yapf,
31
32 # checks
33 flaky,
34 matplotlib,
35 numpy,
36 pandas,
37 pytestCheckHook,
38 websockets,
39
40 testers,
41 python-lsp-server,
42}:
43
44buildPythonPackage rec {
45 pname = "python-lsp-server";
46 version = "1.12.0";
47 pyproject = true;
48
49 disabled = pythonOlder "3.8";
50
51 src = fetchFromGitHub {
52 owner = "python-lsp";
53 repo = "python-lsp-server";
54 rev = "refs/tags/v${version}";
55 hash = "sha256-oFqa7DtFpJmDZrw+GJqrFH3QqnMAu9159q3IWT9vRko=";
56 };
57
58 postPatch = ''
59 substituteInPlace pyproject.toml \
60 --replace-fail "--cov-report html --cov-report term --junitxml=pytest.xml" "" \
61 --replace-fail "--cov pylsp --cov test" ""
62 '';
63
64 pythonRelaxDeps = [
65 "autopep8"
66 "flake8"
67 "mccabe"
68 "pycodestyle"
69 "pydocstyle"
70 "pyflakes"
71 ];
72
73 build-system = [ setuptools-scm ];
74
75 dependencies = [
76 docstring-to-markdown
77 jedi
78 pluggy
79 python-lsp-jsonrpc
80 setuptools # `pkg_resources`imported in pylsp/config/config.py
81 ujson
82 ] ++ lib.optionals (pythonOlder "3.10") [ importlib-metadata ];
83
84 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 = [ autopep8 ];
99 flake8 = [ flake8 ];
100 mccabe = [ mccabe ];
101 pycodestyle = [ pycodestyle ];
102 pydocstyle = [ pydocstyle ];
103 pyflakes = [ pyflakes ];
104 pylint = [ pylint ];
105 rope = [ rope ];
106 yapf = [
107 whatthepatch
108 yapf
109 ];
110 websockets = [ websockets ];
111 };
112
113 nativeCheckInputs = [
114 flaky
115 matplotlib
116 numpy
117 pandas
118 pytestCheckHook
119 ] ++ optional-dependencies.all;
120
121 disabledTests = [
122 # Don't run lint tests
123 "test_pydocstyle"
124 # https://github.com/python-lsp/python-lsp-server/issues/243
125 # "test_numpy_completions"
126 "test_workspace_loads_pycodestyle_config"
127 "test_autoimport_code_actions_and_completions_for_notebook_document"
128 # avoid dependencies on many Qt things just to run one singular test
129 "test_pyqt_completion"
130 ];
131
132 preCheck = ''
133 export HOME=$(mktemp -d);
134 '';
135
136 pythonImportsCheck = [
137 "pylsp"
138 "pylsp.python_lsp"
139 ];
140
141 passthru = {
142 tests.version = testers.testVersion {
143 package = python-lsp-server;
144 version = "v${version}";
145 };
146 };
147
148 meta = {
149 description = "Python implementation of the Language Server Protocol";
150 homepage = "https://github.com/python-lsp/python-lsp-server";
151 changelog = "https://github.com/python-lsp/python-lsp-server/blob/v${version}/CHANGELOG.md";
152 license = lib.licenses.mit;
153 maintainers = with lib.maintainers; [ fab ];
154 mainProgram = "pylsp";
155 };
156}