vscode-common-python-lsp 0.3.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/PKG-INFO +1 -1
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/pyproject.toml +1 -1
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_process_runner.py +53 -1
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/__init__.py +2 -1
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/process_runner.py +19 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp.egg-info/PKG-INFO +1 -1
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/README.md +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/setup.cfg +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_code_actions.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_context.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_debug.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_diagnostics.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_formatting.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_jsonrpc.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_linting.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_notebook.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_package.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_paths.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_runner.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_server.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_version.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/code_actions.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/context.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/debug.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/diagnostics.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/formatting.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/jsonrpc.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/linting.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/notebook.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/paths.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/runner.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/server.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/version.py +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp.egg-info/SOURCES.txt +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp.egg-info/dependency_links.txt +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp.egg-info/requires.txt +0 -0
- {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp.egg-info/top_level.txt +0 -0
{vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_process_runner.py
RENAMED
|
@@ -8,7 +8,11 @@ import unittest
|
|
|
8
8
|
from dataclasses import dataclass
|
|
9
9
|
from unittest.mock import MagicMock
|
|
10
10
|
|
|
11
|
-
from vscode_common_python_lsp.process_runner import
|
|
11
|
+
from vscode_common_python_lsp.process_runner import (
|
|
12
|
+
run_message_loop,
|
|
13
|
+
update_environ_path,
|
|
14
|
+
update_sys_path,
|
|
15
|
+
)
|
|
12
16
|
|
|
13
17
|
|
|
14
18
|
class TestUpdateSysPath(unittest.TestCase):
|
|
@@ -60,6 +64,54 @@ class TestUpdateSysPath(unittest.TestCase):
|
|
|
60
64
|
sys.path[:] = original
|
|
61
65
|
|
|
62
66
|
|
|
67
|
+
class TestUpdateEnvironPath(unittest.TestCase):
|
|
68
|
+
"""Tests for update_environ_path."""
|
|
69
|
+
|
|
70
|
+
def test_adds_scripts_to_path(self):
|
|
71
|
+
import sysconfig
|
|
72
|
+
|
|
73
|
+
scripts = sysconfig.get_path("scripts")
|
|
74
|
+
if not scripts:
|
|
75
|
+
self.skipTest("sysconfig does not report scripts path")
|
|
76
|
+
|
|
77
|
+
# Remove scripts from PATH if present
|
|
78
|
+
original_env = os.environ.copy()
|
|
79
|
+
path_var = "PATH" if "PATH" in os.environ else "Path"
|
|
80
|
+
paths = os.environ.get(path_var, "").split(os.pathsep)
|
|
81
|
+
paths = [p for p in paths if p != scripts]
|
|
82
|
+
os.environ[path_var] = os.pathsep.join(paths)
|
|
83
|
+
|
|
84
|
+
try:
|
|
85
|
+
update_environ_path()
|
|
86
|
+
new_paths = os.environ[path_var].split(os.pathsep)
|
|
87
|
+
assert scripts in new_paths
|
|
88
|
+
assert new_paths[0] == scripts
|
|
89
|
+
finally:
|
|
90
|
+
os.environ.clear()
|
|
91
|
+
os.environ.update(original_env)
|
|
92
|
+
|
|
93
|
+
def test_does_not_duplicate(self):
|
|
94
|
+
import sysconfig
|
|
95
|
+
|
|
96
|
+
scripts = sysconfig.get_path("scripts")
|
|
97
|
+
if not scripts:
|
|
98
|
+
self.skipTest("sysconfig does not report scripts path")
|
|
99
|
+
|
|
100
|
+
original_env = os.environ.copy()
|
|
101
|
+
path_var = "PATH" if "PATH" in os.environ else "Path"
|
|
102
|
+
# Ensure scripts is already in PATH
|
|
103
|
+
os.environ[path_var] = scripts + os.pathsep + os.environ.get(path_var, "")
|
|
104
|
+
|
|
105
|
+
try:
|
|
106
|
+
count_before = os.environ[path_var].split(os.pathsep).count(scripts)
|
|
107
|
+
update_environ_path()
|
|
108
|
+
count_after = os.environ[path_var].split(os.pathsep).count(scripts)
|
|
109
|
+
assert count_after == count_before
|
|
110
|
+
finally:
|
|
111
|
+
os.environ.clear()
|
|
112
|
+
os.environ.update(original_env)
|
|
113
|
+
|
|
114
|
+
|
|
63
115
|
@dataclass
|
|
64
116
|
class _MockResult:
|
|
65
117
|
"""Minimal result object for testing."""
|
|
@@ -59,7 +59,7 @@ from .paths import (
|
|
|
59
59
|
normalize_path,
|
|
60
60
|
reset_caches,
|
|
61
61
|
)
|
|
62
|
-
from .process_runner import run_message_loop, update_sys_path
|
|
62
|
+
from .process_runner import run_message_loop, update_environ_path, update_sys_path
|
|
63
63
|
from .runner import CustomIO, RunResult, run_api, run_module, run_path
|
|
64
64
|
from .server import ToolServer, ToolServerConfig
|
|
65
65
|
from .version import VersionInfo, check_min_version, extract_version, version_to_tuple
|
|
@@ -98,6 +98,7 @@ __all__ = [
|
|
|
98
98
|
"shutdown_json_rpc",
|
|
99
99
|
# process_runner
|
|
100
100
|
"update_sys_path",
|
|
101
|
+
"update_environ_path",
|
|
101
102
|
"run_message_loop",
|
|
102
103
|
# debug
|
|
103
104
|
"setup_debugpy",
|
|
@@ -6,6 +6,7 @@ from __future__ import annotations
|
|
|
6
6
|
|
|
7
7
|
import os
|
|
8
8
|
import sys
|
|
9
|
+
import sysconfig
|
|
9
10
|
import traceback
|
|
10
11
|
from collections.abc import Callable
|
|
11
12
|
from typing import TYPE_CHECKING
|
|
@@ -34,6 +35,24 @@ def update_sys_path(path_to_add: str, strategy: str) -> None:
|
|
|
34
35
|
sys.path.append(path_to_add)
|
|
35
36
|
|
|
36
37
|
|
|
38
|
+
def update_environ_path() -> None:
|
|
39
|
+
"""Update PATH environment variable with the ``scripts`` directory.
|
|
40
|
+
|
|
41
|
+
Ensures tool executables installed in the virtual environment's scripts
|
|
42
|
+
directory (``Scripts`` on Windows, ``bin`` on Unix) are discoverable.
|
|
43
|
+
"""
|
|
44
|
+
scripts = sysconfig.get_path("scripts")
|
|
45
|
+
if not scripts:
|
|
46
|
+
return
|
|
47
|
+
for var_name in ("Path", "PATH"):
|
|
48
|
+
if var_name in os.environ:
|
|
49
|
+
paths = os.environ[var_name].split(os.pathsep)
|
|
50
|
+
if scripts not in paths:
|
|
51
|
+
paths.insert(0, scripts)
|
|
52
|
+
os.environ[var_name] = os.pathsep.join(paths)
|
|
53
|
+
break
|
|
54
|
+
|
|
55
|
+
|
|
37
56
|
def run_message_loop(
|
|
38
57
|
rpc: JsonRpc,
|
|
39
58
|
run_fn: Callable[..., object],
|
|
File without changes
|
|
File without changes
|
{vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_code_actions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/debug.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/paths.py
RENAMED
|
File without changes
|
{vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/runner.py
RENAMED
|
File without changes
|
{vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/server.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|