Skip to content

Commit c6820a9

Browse files
committed
Include Python runtime in CLI version output
1 parent a362006 commit c6820a9

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ Only on Alpine Linux the package is named differently. You can install it there
7676
apk add py3-lsp-server
7777
```
7878

79+
Run `pylsp --version` (or `pylsp -V`) to see both the server version and the
80+
Python version running it. This reports the server runtime, which may differ
81+
from the interpreter or target Python version configured for individual plugins.
82+
7983
### 3rd Party Plugins
8084

8185
Installing these plugins will add extra functionality to the language server:

‎pylsp/__main__.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import argparse
55
import logging
66
import logging.config
7+
import platform
78
import sys
89
import time
910

@@ -63,7 +64,10 @@ def add_arguments(parser) -> None:
6364
)
6465

6566
parser.add_argument(
66-
"-V", "--version", action="version", version="%(prog)s v" + __version__
67+
"-V",
68+
"--version",
69+
action="version",
70+
version=f"%(prog)s v{__version__} (Python {platform.python_version()})",
6771
)
6872

6973

‎test/test_main.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2021- Python Language Server Contributors.
2+
3+
import platform
4+
import subprocess
5+
import sys
6+
7+
import pytest
8+
9+
from pylsp._version import __version__
10+
11+
12+
@pytest.mark.parametrize("flag", ["--version", "-V"])
13+
def test_version_includes_python_runtime(flag):
14+
result = subprocess.run(
15+
[sys.executable, "-m", "pylsp", flag],
16+
capture_output=True,
17+
text=True,
18+
check=True,
19+
timeout=10,
20+
)
21+
assert f"v{__version__}" in result.stdout
22+
assert f"Python {platform.python_version()}" in result.stdout
23+
assert result.stderr == ""

0 commit comments

Comments
 (0)