Skip to content

Commit b63f5ee

Browse files
committed
try using python -m for pyls
1 parent 8269277 commit b63f5ee

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

py_src/jupyter_lsp/specs/pyls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from .config import load_config_schema
2-
from .utils import ShellSpec
2+
from .utils import PythonModuleSpec
33

44

5-
class PythonLanguageServer(ShellSpec):
6-
key = cmd = "pyls"
5+
class PythonLanguageServer(PythonModuleSpec):
6+
python_module = key = "pyls"
77
languages = ["python"]
88
spec = dict(
99
display_name="pyls",

py_src/jupyter_lsp/specs/utils.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import shutil
3+
import sys
34
from pathlib import Path
45
from typing import List, Text
56

@@ -61,6 +62,29 @@ def __call__(self, mgr: LanguageServerManagerAPI) -> KeyedLanguageServerSpecs:
6162
}
6263

6364

65+
class PythonModuleSpec(SpecBase):
66+
""" Helper for a python-based language server spec in the notebook server
67+
environment
68+
"""
69+
70+
python_module = ""
71+
72+
def __call__(self, mgr: LanguageServerManagerAPI) -> KeyedLanguageServerSpecs:
73+
spec = __import__("importlib").util.find_spec(self.python_module)
74+
75+
if not spec.origin: # pragma: no cover
76+
return {}
77+
78+
return {
79+
self.key: {
80+
"argv": [sys.executable, "-m", self.python_module, *self.args],
81+
"languages": self.languages,
82+
"version": SPEC_VERSION,
83+
**self.spec,
84+
}
85+
}
86+
87+
6488
class NodeModuleSpec(SpecBase):
6589
""" Helper for a nodejs-based language server spec in one of several
6690
node_modules

0 commit comments

Comments
 (0)