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.
Files changed (37) hide show
  1. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/PKG-INFO +1 -1
  2. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/pyproject.toml +1 -1
  3. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_process_runner.py +53 -1
  4. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/__init__.py +2 -1
  5. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/process_runner.py +19 -0
  6. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp.egg-info/PKG-INFO +1 -1
  7. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/README.md +0 -0
  8. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/setup.cfg +0 -0
  9. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_code_actions.py +0 -0
  10. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_context.py +0 -0
  11. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_debug.py +0 -0
  12. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_diagnostics.py +0 -0
  13. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_formatting.py +0 -0
  14. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_jsonrpc.py +0 -0
  15. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_linting.py +0 -0
  16. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_notebook.py +0 -0
  17. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_package.py +0 -0
  18. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_paths.py +0 -0
  19. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_runner.py +0 -0
  20. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_server.py +0 -0
  21. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/tests/test_version.py +0 -0
  22. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/code_actions.py +0 -0
  23. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/context.py +0 -0
  24. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/debug.py +0 -0
  25. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/diagnostics.py +0 -0
  26. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/formatting.py +0 -0
  27. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/jsonrpc.py +0 -0
  28. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/linting.py +0 -0
  29. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/notebook.py +0 -0
  30. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/paths.py +0 -0
  31. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/runner.py +0 -0
  32. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/server.py +0 -0
  33. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp/version.py +0 -0
  34. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp.egg-info/SOURCES.txt +0 -0
  35. {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
  36. {vscode_common_python_lsp-0.3.0 → vscode_common_python_lsp-0.4.0}/vscode_common_python_lsp.egg-info/requires.txt +0 -0
  37. {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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vscode-common-python-lsp
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Shared Python utilities for VS Code Python tool extensions
5
5
  Author: Microsoft Corporation
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "vscode-common-python-lsp"
7
- version = "0.3.0"
7
+ version = "0.4.0"
8
8
  description = "Shared Python utilities for VS Code Python tool extensions"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -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 run_message_loop, update_sys_path
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],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vscode-common-python-lsp
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Shared Python utilities for VS Code Python tool extensions
5
5
  Author: Microsoft Corporation
6
6
  License-Expression: MIT