1{ stdenv, buildPythonPackage, fetchFromGitHub, pythonOlder, isPy27
2, configparser, futures, future, jedi, pluggy, python-jsonrpc-server
3, pytest, mock, pytestcov, coverage
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, rope ? null
14, yapf ? null
15}:
16
17let
18 withProvider = p: builtins.elem "*" providers || builtins.elem p providers;
19in
20
21buildPythonPackage rec {
22 pname = "python-language-server";
23 version = "0.21.2";
24
25 src = fetchFromGitHub {
26 owner = "palantir";
27 repo = "python-language-server";
28 rev = version;
29 sha256 = "11fvrpv1kymj2fzh8fhys4qk1xc64j1rbdrz252awyab7b3509i7";
30 };
31
32 # The tests require all the providers, disable otherwise.
33 doCheck = providers == ["*"];
34
35 checkInputs = [
36 pytest mock pytestcov coverage
37 # rope is technically a dependency, but we don't add it by default since we
38 # already have jedi, which is the preferred option
39 rope
40 ];
41
42 checkPhase = ''
43 HOME=$TEMPDIR pytest
44 '';
45
46 propagatedBuildInputs = [ jedi pluggy future python-jsonrpc-server ]
47 ++ stdenv.lib.optional (withProvider "autopep8") autopep8
48 ++ stdenv.lib.optional (withProvider "mccabe") mccabe
49 ++ stdenv.lib.optional (withProvider "pycodestyle") pycodestyle
50 ++ stdenv.lib.optional (withProvider "pydocstyle") pydocstyle
51 ++ stdenv.lib.optional (withProvider "pyflakes") pyflakes
52 ++ stdenv.lib.optional (withProvider "rope") rope
53 ++ stdenv.lib.optional (withProvider "yapf") yapf
54 ++ stdenv.lib.optional isPy27 configparser
55 ++ stdenv.lib.optional (pythonOlder "3.2") futures;
56
57 meta = with stdenv.lib; {
58 homepage = https://github.com/palantir/python-language-server;
59 description = "An implementation of the Language Server Protocol for Python";
60 license = licenses.mit;
61 maintainers = [ maintainers.mic92 ];
62 };
63}