3
0
Fork 0
forked from mirrors/nixpkgs

python-language-server: add providers option

Adding all of the extra dependencies isn't always desirable and
overriding a bunch of inputs is a bit cumbersome and brittle.

eg.

python-language-server.override { providers = ["rope"]; }
This commit is contained in:
Daiderd Jordan 2018-08-06 20:41:52 +02:00
parent d12afcf734
commit 5b2ff69544
No known key found for this signature in database
GPG key ID: D02435D05B810C96

View file

@ -1,18 +1,23 @@
{ lib, buildPythonPackage, fetchFromGitHub, pythonOlder, isPy27
{ stdenv, buildPythonPackage, fetchFromGitHub, pythonOlder, isPy27
, configparser, futures, future, jedi, pluggy
, pytest, mock, pytestcov, coverage
# The following packages are optional and
# can be overwritten with null as your liking.
# This also requires to disable tests.
, rope ? null
, mccabe ? null
, pyflakes ? null
, pycodestyle ? null
, # Allow building a limited set of providers, e.g. ["pycodestyle"].
providers ? ["*"]
# The following packages are optional and
# can be overwritten with null as your liking.
, autopep8 ? null
, yapf ? null
, mccabe ? null
, pycodestyle ? null
, pydocstyle ? null
, pyflakes ? null
, rope ? null
, yapf ? null
}:
let
withProvider = p: builtins.elem "*" providers || builtins.elem p providers;
in
buildPythonPackage rec {
pname = "python-language-server";
version = "0.19.0";
@ -24,22 +29,32 @@ buildPythonPackage rec {
sha256 = "0glnhnjmsnnh1vs73n9dglknfkhcgp03nkjbpz0phh1jlqrkrwm6";
};
# The tests require all the providers, disable otherwise.
doCheck = providers == ["*"];
checkInputs = [
pytest mock pytestcov coverage
# rope is technically a dependency, but we don't add it by default since we
# already have jedi, which is the preferred option
rope
];
checkPhase = ''
HOME=$TEMPDIR pytest
'';
propagatedBuildInputs = [
jedi pluggy mccabe pyflakes pycodestyle yapf pydocstyle future autopep8
] ++ lib.optional (isPy27) [ configparser ]
++ lib.optional (pythonOlder "3.2") [ futures ];
propagatedBuildInputs = [ jedi pluggy future ]
++ stdenv.lib.optional (withProvider "autopep8") autopep8
++ stdenv.lib.optional (withProvider "mccabe") mccabe
++ stdenv.lib.optional (withProvider "pycodestyle") pycodestyle
++ stdenv.lib.optional (withProvider "pydocstyle") pydocstyle
++ stdenv.lib.optional (withProvider "pyflakes") pyflakes
++ stdenv.lib.optional (withProvider "rope") rope
++ stdenv.lib.optional (withProvider "yapf") yapf
++ stdenv.lib.optional isPy27 configparser
++ stdenv.lib.optional (pythonOlder "3.2") futures;
meta = with lib; {
meta = with stdenv.lib; {
homepage = https://github.com/palantir/python-language-server;
description = "An implementation of the Language Server Protocol for Python";
license = licenses.mit;