1{ stdenv, buildPythonPackage, fetchFromGitHub, fetchpatch, pythonOlder, isPy27
2, backports_functools_lru_cache, configparser, futures, future, jedi, pluggy, python-jsonrpc-server, flake8
3, pytestCheckHook, mock, pytestcov, coverage, setuptools, ujson
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.34.1";
25
26 src = fetchFromGitHub {
27 owner = "palantir";
28 repo = "python-language-server";
29 rev = version;
30 sha256 = "sha256-/tVzaoyUO6+7DSvnf3JxpcTY0rU+hHBu5qlru/ZTpxU=";
31 };
32
33 patches = [
34 # https://github.com/palantir/python-language-server/pull/851
35 (fetchpatch {
36 url = "https://github.com/palantir/python-language-server/commit/f513f3297132492dd41e001d943980e6c4f40809.patch";
37 sha256 = "04c9hrb3dzlfchjk4625ipazyfcbq6qq2kj2hg3zf2xsny2jcvi5";
38 })
39 ];
40
41 postPatch = ''
42 # https://github.com/palantir/python-jsonrpc-server/issues/36
43 sed -i -e 's!ujson<=!ujson>=!' setup.py
44 '';
45
46 # The tests require all the providers, disable otherwise.
47 doCheck = providers == ["*"];
48
49 checkInputs = [
50 pytestCheckHook mock pytestcov coverage
51 # rope is technically a dependency, but we don't add it by default since we
52 # already have jedi, which is the preferred option
53 rope
54 ];
55
56 dontUseSetuptoolsCheck = true;
57
58 preCheck = ''
59 export HOME=$TEMPDIR
60 '';
61
62 # Tests failed since update to 0.31.8
63 disabledTests = [
64 "test_pyqt_completion"
65 "test_numpy_completions"
66 "test_pandas_completions"
67 "test_matplotlib_completions"
68 "test_snippet_parsing"
69 "test_numpy_hover"
70 ] ++ stdenv.lib.optional isPy27 "test_flake8_lint";
71
72 propagatedBuildInputs = [ setuptools jedi pluggy future python-jsonrpc-server flake8 ujson ]
73 ++ stdenv.lib.optional (withProvider "autopep8") autopep8
74 ++ stdenv.lib.optional (withProvider "mccabe") mccabe
75 ++ stdenv.lib.optional (withProvider "pycodestyle") pycodestyle
76 ++ stdenv.lib.optional (withProvider "pydocstyle") pydocstyle
77 ++ stdenv.lib.optional (withProvider "pyflakes") pyflakes
78 ++ stdenv.lib.optional (withProvider "pylint") pylint
79 ++ stdenv.lib.optional (withProvider "rope") rope
80 ++ stdenv.lib.optional (withProvider "yapf") yapf
81 ++ stdenv.lib.optional isPy27 configparser
82 ++ stdenv.lib.optionals (pythonOlder "3.2") [ backports_functools_lru_cache futures ];
83
84 meta = with stdenv.lib; {
85 homepage = "https://github.com/palantir/python-language-server";
86 description = "An implementation of the Language Server Protocol for Python";
87 license = licenses.mit;
88 maintainers = [ maintainers.mic92 ];
89 };
90}