1{ lib, buildPythonPackage, fetchFromGitHub, pythonAtLeast, pythonOlder, isPy27
2, backports_functools_lru_cache ? null, configparser ? null, futures ? null, future, jedi, pluggy, python-jsonrpc-server, flake8
3, pytestCheckHook, mock, pytestcov, coverage, setuptools, ujson, flaky
4, # Allow building a limited set of providers, e.g. ["pycodestyle"].
5 providers ? ["*"]
6 # The following packages are optional and
7 # can be overwritten with null as your liking.
8, autopep8 ? null
9, mccabe ? null
10, pycodestyle ? null
11, pydocstyle ? null
12, pyflakes ? null
13, pylint ? null
14, rope ? null
15, yapf ? null
16}:
17
18let
19 withProvider = p: builtins.elem "*" providers || builtins.elem p providers;
20in
21
22buildPythonPackage rec {
23 pname = "python-language-server";
24 version = "0.36.2";
25 # https://github.com/palantir/python-language-server/issues/896#issuecomment-752790868
26 disabled = pythonAtLeast "3.9";
27
28 src = fetchFromGitHub {
29 owner = "palantir";
30 repo = "python-language-server";
31 rev = version;
32 sha256 = "07x6jr4z20jxn03bxblwc8vk0ywha492cgwfhj7q97nb5cm7kx0q";
33 };
34
35 postPatch = ''
36 # Reading the changelog I don't expect an API break in pycodestyle and pyflakes
37 substituteInPlace setup.py \
38 --replace "pycodestyle>=2.6.0,<2.7.0" "pycodestyle>=2.6.0,<2.8.0" \
39 --replace "pyflakes>=2.2.0,<2.3.0" "pyflakes>=2.2.0,<2.4.0"
40 '';
41
42 propagatedBuildInputs = [ setuptools jedi pluggy future python-jsonrpc-server ujson ]
43 ++ lib.optional (withProvider "autopep8") autopep8
44 ++ lib.optional (withProvider "mccabe") mccabe
45 ++ lib.optional (withProvider "pycodestyle") pycodestyle
46 ++ lib.optional (withProvider "pydocstyle") pydocstyle
47 ++ lib.optional (withProvider "pyflakes") pyflakes
48 ++ lib.optional (withProvider "pylint") pylint
49 ++ lib.optional (withProvider "rope") rope
50 ++ lib.optional (withProvider "yapf") yapf
51 ++ lib.optional isPy27 configparser
52 ++ lib.optionals (pythonOlder "3.2") [ backports_functools_lru_cache futures ];
53
54 # The tests require all the providers, disable otherwise.
55 doCheck = providers == ["*"];
56
57 checkInputs = [
58 pytestCheckHook mock pytestcov coverage flaky
59 # Do not propagate flake8 or it will enable pyflakes implicitly
60 flake8
61 # rope is technically a dependency, but we don't add it by default since we
62 # already have jedi, which is the preferred option
63 rope
64 ];
65
66 dontUseSetuptoolsCheck = true;
67
68 preCheck = ''
69 export HOME=$TEMPDIR
70 '';
71
72 # Tests failed since update to 0.31.8
73 disabledTests = [
74 "test_pyqt_completion"
75 "test_numpy_completions"
76 "test_pandas_completions"
77 "test_matplotlib_completions"
78 "test_snippet_parsing"
79 "test_numpy_hover"
80 "test_symbols"
81 ] ++ lib.optional isPy27 "test_flake8_lint";
82
83 meta = with lib; {
84 homepage = "https://github.com/palantir/python-language-server";
85 description = "An implementation of the Language Server Protocol for Python";
86 license = licenses.mit;
87 maintainers = [ maintainers.mic92 ];
88 };
89}