# microsoft/vscode-python architecture

> Architecture diagram of the GitHub repository microsoft/vscode-python, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoft/vscode-python
- Repository: https://github.com/microsoft/vscode-python

## Overview

1. This repository is the VS Code Python extension, not a standalone app. The primary runtime is the VS Code extension host (TypeScript/Node.js), with a large set of Python helper scripts executed as subprocesses for environment discovery, test running, REPL, and terminal integration.

2. The top-level architecture is split into three major planes:
   - `src/client`: the extension code that runs inside VS Code
   - `python_files`: Python-side helpers and adapters launched by the extension
   - `src/test` plus `python_files/tests`: extensive unit, functional, and smoke coverage for both the TS and Python halves

3. `src/client/extension.ts` and the activation layer are the entry point. From there, the extension wires feature services through dependency injection/service registries under `src/client/ioc`, `src/client/common/serviceRegistry.ts`, and feature-specific registries. This makes the feature subsystems relatively decoupled while still sharing platform, process, and configuration services.

4. Interpreter and environment management is a core subsystem. `src/client/pythonEnvironments`, `src/client/interpreter`, and `src/client/common/installer` collectively discover interpreters, model environment kinds, select the active interpreter, create/delete environments, and surface installation prompts. The repo supports multiple environment ecosystems: venv/virtualenv, conda, pipenv, poetry, pyenv, hatch, pixi, and Microsoft Store Python.

5. Environment discovery is layered. Low-level locators in `src/client/pythonEnvironments/base/locators/lowLevel` scan the filesystem, registry, and known paths; composite locators and reducers aggregate results; watchers keep the environment cache updated. This subsystem is designed to react to filesystem changes and workspace changes rather than doing one-time discovery.

6. Terminal and shell behavior is another major boundary. `src/client/common/terminal`, `src/client/terminals`, and `python_files/deactivate/*` manage shell detection, environment activation, and terminal-based execution. Different shells and activation styles are handled explicitly, so the extension can inject the correct activation commands and maintain environment context in integrated terminals.

7. Language intelligence is delegated through optional companion extensions and internal adapters. The repo includes activation managers for Pylance, Jedi, and a “none” language server mode under `src/client/languageServer` and `src/client/activation`. The README’s optional dependencies are material to the architecture: Pylance supplies IntelliSense, while the Python extension coordinates settings, extension installation, and fallback behavior.

8. Debugging is handled by a dedicated subsystem under `src/client/debugger`. It owns debug configuration resolution, attach/launch support, child-process attach hooks, and integration points for `debugpy`. The code is structured around launch.json parsing, configuration resolvers, and debugger adapters rather than embedding debug logic in the general extension flow.

9. Testing is a first-class feature area. `src/client/testing` implements the Test Explorer integration, with separate pytest and unittest controllers/adapters plus discovery, execution, coverage, and result resolution. The Python-side adapters in `python_files/unittestadapter`, `python_files/vscode_pytest`, and `python_files/tests/*` run discovery/execution in Python and translate results back to VS Code test items and events.

10. Jupyter, REPL, and code execution are separate integration surfaces. `src/client/jupyter` coordinates notebook-related prompts and dependency checks; `src/client/repl` handles interactive REPL behavior and variable inspection; `src/client/terminals/codeExecution` and `src/client/providers` connect “run file” and “run selection” workflows to terminals and execution helpers.

11. The Python helper layer is an important architectural boundary. Scripts like `python_server.py`, `interpreterInfo.py`, `get_variable_info.py`, `create_venv.py`, `create_conda.py`, `run-jedi-language-server.py`, and the unittest/pytest adapters are launched from TS to perform Python-native operations that are awkward or unreliable from Node.js. Communication is typically via stdout markers, sockets, files, or process exit codes.

12. There is explicit support for browser/partial mode and workspace-limited behavior. `src/client/browser` and the README’s vscode.dev notes indicate a reduced-capability path where only some features are available. In practice, this means the extension has to branch based on host capabilities, filesystem access, and whether it can spawn local Python processes.

13. Telemetry, diagnostics, and user guidance are their own subsystem rather than ad hoc logging. `src/client/telemetry`, `src/client/application/diagnostics`, and the `resources/walkthrough` / report-issue templates implement feature usage reporting, environment diagnostics, and guided remediation flows. This is important for architecture diagrams because these flows often originate from feature failures and feed into prompts, commands, and issue reporting.

14. Build and release infrastructure is substantial and repo-specific. Webpack builds package the extension and browser variant; gulp/build scripts and `build/` support packaging, version updates, and test execution; GitHub Actions and Azure pipeline files drive CI, smoke tests, linting, and VSIX creation. The repo is therefore split not just by runtime but also by delivery targets: VS Code desktop, browser, and release packaging.

15. The companion package in `pythonExtensionApi` is a separate publishable surface for other extensions to consume Python-extension APIs. It acts as an API boundary, distinct from the main extension implementation, and helps explain why some capabilities are exposed as typed contracts rather than direct internal imports.

Main entry points: [`src/client/ioc/container.ts`](https://github.com/microsoft/vscode-python/blob/main/src/client/ioc/container.ts) (Service DI), [`src/client/extension.ts`](https://github.com/microsoft/vscode-python/blob/main/src/client/extension.ts) (Extension entry), [`python_files/interpreterInfo.py`](https://github.com/microsoft/vscode-python/blob/main/python_files/interpreterInfo.py) (Py helpers), [`src/client/interpreter/interpreterService.ts`](https://github.com/microsoft/vscode-python/blob/main/src/client/interpreter/interpreterService.ts) (Env manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["VS Code client"]
  node_extension_entry["Extension entry<br/>TS activation<br/>[extension.ts]"]
  node_service_registry["Service DI<br/>IOC/registry<br/>[container.ts]"]
  node_core_services["Core services<br/>platform/process<br/>[serviceRegistry.ts]"]
  node_env_mgmt["Env manager<br/>interpreter/env"]
  node_env_discovery["Env discovery<br/>locators/watchers<br/>[locators.ts]"]
  node_env_creation["Env creation<br/>venv/conda"]
  node_terminal_shell["Terminal shell<br/>activation/exec<br/>[service.ts]"]
  node_language_server["Language server<br/>Pylance/Jedi/none"]
  node_debugger["Debugger<br/>launch/attach<br/>[pythonDebugger.ts]"]
  node_testing["Testing<br/>test explorer<br/>[controller.ts]"]
  node_jupyter_repl["Jupyter/REPL<br/>notebook/interactive<br/>[replController.ts]"]
  node_code_exec["Run in terminal<br/>code execution"]
  node_telemetry_diag["Telemetry/diag<br/>telemetry/support"]
  node_browser_mode["Browser mode<br/>partial host<br/>[extension.ts]"]
  node_api_boundary["API boundary<br/>public API<br/>[main.ts]"]
end

subgraph group_python["Python helpers"]
  node_python_server["Python server<br/>subprocess API<br/>[python_server.py]"]
  node_py_helpers["Py helpers<br/>scripts/adapters<br/>[interpreterInfo.py]"]
  node_py_testing_adapters["Py test adapters<br/>pytest/unittest<br/>[discovery.py]"]
end

subgraph group_qa["Testing"]
  node_ts_tests["TS tests<br/>unit/functional/smoke<br/>[testRunner.ts]"]
  node_py_tests["Py tests<br/>adapter fixtures<br/>[run_all.py]"]
end

subgraph group_delivery["Delivery"]
  node_build_release["Build/release<br/>webpack/CI"]
end

node_extension_entry -->|"boots"| node_service_registry
node_service_registry -->|"wires"| node_core_services
node_service_registry -->|"provides"| node_env_mgmt
node_service_registry -->|"provides"| node_terminal_shell
node_service_registry -->|"provides"| node_language_server
node_service_registry -->|"provides"| node_debugger
node_service_registry -->|"provides"| node_testing
node_service_registry -->|"provides"| node_telemetry_diag
node_env_mgmt -->|"discovers"| node_env_discovery
node_env_mgmt -->|"creates"| node_env_creation
node_env_discovery -->|"uses"| node_core_services
node_env_creation -->|"spawns"| node_py_helpers
node_terminal_shell -->|"executes"| node_py_helpers
node_code_exec -->|"routes through"| node_terminal_shell
node_jupyter_repl -->|"communicates"| node_py_helpers
node_debugger -->|"launches"| node_python_server
node_testing -->|"delegates"| node_py_testing_adapters
node_testing -->|"coordinates"| node_python_server
node_language_server -->|"adapts"| node_browser_mode
node_telemetry_diag -->|"observes"| node_extension_entry
node_api_boundary -->|"exposes"| node_extension_entry
node_ts_tests -->|"covers"| node_extension_entry
node_py_tests -->|"covers"| node_py_helpers
node_build_release -->|"packages"| node_extension_entry
node_build_release -->|"packages"| node_browser_mode

click node_extension_entry "https://github.com/microsoft/vscode-python/blob/main/src/client/extension.ts"
click node_service_registry "https://github.com/microsoft/vscode-python/blob/main/src/client/ioc/container.ts"
click node_core_services "https://github.com/microsoft/vscode-python/blob/main/src/client/common/serviceRegistry.ts"
click node_env_mgmt "https://github.com/microsoft/vscode-python/blob/main/src/client/interpreter/interpreterService.ts"
click node_env_discovery "https://github.com/microsoft/vscode-python/blob/main/src/client/pythonEnvironments/base/locators.ts"
click node_env_creation "https://github.com/microsoft/vscode-python/blob/main/src/client/pythonEnvironments/creation/createEnvironment.ts"
click node_terminal_shell "https://github.com/microsoft/vscode-python/blob/main/src/client/common/terminal/service.ts"
click node_language_server "https://github.com/microsoft/vscode-python/blob/main/src/client/languageServer/pylanceLSExtensionManager.ts"
click node_debugger "https://github.com/microsoft/vscode-python/blob/main/src/client/debugger/pythonDebugger.ts"
click node_testing "https://github.com/microsoft/vscode-python/blob/main/src/client/testing/testController/controller.ts"
click node_jupyter_repl "https://github.com/microsoft/vscode-python/blob/main/src/client/repl/replController.ts"
click node_code_exec "https://github.com/microsoft/vscode-python/blob/main/src/client/terminals/codeExecution/codeExecutionManager.ts"
click node_telemetry_diag "https://github.com/microsoft/vscode-python/blob/main/src/client/application/diagnostics/applicationDiagnostics.ts"
click node_browser_mode "https://github.com/microsoft/vscode-python/blob/main/src/client/browser/extension.ts"
click node_python_server "https://github.com/microsoft/vscode-python/blob/main/python_files/python_server.py"
click node_py_helpers "https://github.com/microsoft/vscode-python/blob/main/python_files/interpreterInfo.py"
click node_py_testing_adapters "https://github.com/microsoft/vscode-python/blob/main/python_files/unittestadapter/discovery.py"
click node_api_boundary "https://github.com/microsoft/vscode-python/blob/main/pythonExtensionApi/src/main.ts"
click node_ts_tests "https://github.com/microsoft/vscode-python/blob/main/src/test/testRunner.ts"
click node_py_tests "https://github.com/microsoft/vscode-python/blob/main/python_files/tests/run_all.py"
click node_build_release "https://github.com/microsoft/vscode-python/blob/main/build/webpack/webpack.extension.config.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_extension_entry,node_service_registry,node_core_services,node_env_mgmt,node_env_discovery,node_env_creation,node_terminal_shell,node_language_server,node_debugger,node_testing,node_jupyter_repl,node_code_exec,node_telemetry_diag,node_browser_mode,node_api_boundary toneBlue
class node_python_server,node_py_helpers,node_py_testing_adapters toneAmber
class node_ts_tests,node_py_tests toneMint
class node_build_release toneRose
```

## Components

### VS Code client

TypeScript extension host runtime inside VS Code

- [Extension entry](https://github.com/microsoft/vscode-python/blob/main/src/client/extension.ts): TS activation · Activates the extension and starts feature wiring. · `src/client/extension.ts`
- [Service DI](https://github.com/microsoft/vscode-python/blob/main/src/client/ioc/container.ts): IOC/registry · Shared service containers and feature registries. · `src/client/ioc/container.ts`
- [Core services](https://github.com/microsoft/vscode-python/blob/main/src/client/common/serviceRegistry.ts): platform/process · Shared platform, process, workspace, config, and VS Code abstractions. · `src/client/common/serviceRegistry.ts`
- [Env manager](https://github.com/microsoft/vscode-python/blob/main/src/client/interpreter/interpreterService.ts): interpreter/env · Interpreter selection, environment modeling, and creation prompts. · `src/client/interpreter/interpreterService.ts`
- [Env discovery](https://github.com/microsoft/vscode-python/blob/main/src/client/pythonEnvironments/base/locators.ts): locators/watchers · Filesystem and registry-backed discovery with cache/watch refresh. · `src/client/pythonEnvironments/base/locators.ts`
- [Env creation](https://github.com/microsoft/vscode-python/blob/main/src/client/pythonEnvironments/creation/createEnvironment.ts): venv/conda · Creates, deletes, and validates environments across supported managers. · `src/client/pythonEnvironments/creation/createEnvironment.ts`
- [Terminal shell](https://github.com/microsoft/vscode-python/blob/main/src/client/common/terminal/service.ts): activation/exec · Shell detection, activation commands, and terminal-based execution. · `src/client/common/terminal/service.ts`
- [Language server](https://github.com/microsoft/vscode-python/blob/main/src/client/languageServer/pylanceLSExtensionManager.ts): Pylance/Jedi/none · Optional language server coordination and fallback mode handling. · `src/client/languageServer/pylanceLSExtensionManager.ts`
- [Debugger](https://github.com/microsoft/vscode-python/blob/main/src/client/debugger/pythonDebugger.ts): launch/attach · Debug configuration resolution, attach hooks, and debugpy integration. · `src/client/debugger/pythonDebugger.ts`
- [Testing](https://github.com/microsoft/vscode-python/blob/main/src/client/testing/testController/controller.ts): test explorer · pytest/unittest controllers, discovery, execution, coverage, and results. · `src/client/testing/testController/controller.ts`
- [Jupyter/REPL](https://github.com/microsoft/vscode-python/blob/main/src/client/repl/replController.ts): notebook/interactive · Notebook prompts, REPL, variable inspection, and interactive execution. · `src/client/repl/replController.ts`
- [Run in terminal](https://github.com/microsoft/vscode-python/blob/main/src/client/terminals/codeExecution/codeExecutionManager.ts): code execution · Run file and selection workflows routed through terminals and helpers. · `src/client/terminals/codeExecution/codeExecutionManager.ts`
- [Telemetry/diag](https://github.com/microsoft/vscode-python/blob/main/src/client/application/diagnostics/applicationDiagnostics.ts): telemetry/support · Diagnostics, prompts, walkthroughs, and usage reporting. · `src/client/application/diagnostics/applicationDiagnostics.ts`
- [Browser mode](https://github.com/microsoft/vscode-python/blob/main/src/client/browser/extension.ts): partial host · Reduced-capability path for vscode.dev and browser hosts. · `src/client/browser/extension.ts`
- [API boundary](https://github.com/microsoft/vscode-python/blob/main/pythonExtensionApi/src/main.ts): public API · Publishable typed surface for other extensions. · `pythonExtensionApi/src/main.ts`

### Python helpers

Subprocess-launched Python-side scripts and adapters

- [Python server](https://github.com/microsoft/vscode-python/blob/main/python_files/python_server.py): subprocess API · Main Python helper entrypoint for marker-based IPC and native operations. · `python_files/python_server.py`
- [Py helpers](https://github.com/microsoft/vscode-python/blob/main/python_files/interpreterInfo.py): scripts/adapters · Interpreter info, environment creation, variable inspection, and execution scripts. · `python_files/interpreterInfo.py`
- [Py test adapters](https://github.com/microsoft/vscode-python/blob/main/python_files/unittestadapter/discovery.py): pytest/unittest · Python-side discovery and execution adapters for VS Code testing. · `python_files/unittestadapter/discovery.py`

### Testing

TS and Python test coverage and fixtures

- [TS tests](https://github.com/microsoft/vscode-python/blob/main/src/test/testRunner.ts): unit/functional/smoke · TypeScript-side unit, functional, and smoke coverage. · `src/test/testRunner.ts`
- [Py tests](https://github.com/microsoft/vscode-python/blob/main/python_files/tests/run_all.py): adapter fixtures · Python-side tests and fixture corpora for helpers and adapters. · `python_files/tests/run_all.py`

### Delivery

Build, packaging, and release infrastructure

- [Build/release](https://github.com/microsoft/vscode-python/blob/main/build/webpack/webpack.extension.config.js): webpack/CI · Packaging, versioning, CI pipelines, and VSIX release automation. · `build/webpack/webpack.extension.config.js`

## Connections

- Extension entry → Service DI: boots · Activation initializes shared registries and dependency injection.
- Service DI → Core services: wires · Registries compose platform, process, and workspace services.
- Service DI → Env manager: provides · Interpreter and environment services are injected into features.
- Service DI → Terminal shell: provides · Terminal services are shared with activation and execution flows.
- Service DI → Language server: provides · Language-server mode selection is managed through services.
- Service DI → Debugger: provides · Debugger integration is wired through dedicated registries.
- Service DI → Testing: provides · Testing controllers and adapters are constructed from shared services.
- Service DI → Telemetry/diag: provides · Diagnostics and telemetry consume shared app services.
- Env manager → Env discovery: discovers · Interpreter selection depends on locator and watcher results.
- Env manager → Env creation: creates · Environment management delegates to creation/deletion providers.
- Env discovery → Core services: uses · Discovery reads filesystem, registry, and workspace state.
- Env creation → Py helpers: spawns · Creation flows often call Python subprocess helpers.
- Terminal shell → Py helpers: executes · Terminal activation and code execution rely on helper scripts.
- Run in terminal → Terminal shell: routes through · Run-file and run-selection use terminal/shell integration.
- Jupyter/REPL → Py helpers: communicates · REPL and variable inspection use Python-native helper processes.
- Debugger → Python server: launches · Debugger flows use Python-side entrypoints and hooks.
- Testing → Py test adapters: delegates · Discovery and execution are offloaded to Python adapters.
- Testing → Python server: coordinates · Some test workflows rely on subprocess IPC helpers.
- Language server → Browser mode: adapts · Language-server behavior changes in browser and partial host mode.
- Telemetry/diag → Extension entry: observes · Diagnostics and telemetry are triggered from feature failures and activation.
- API boundary → Extension entry: exposes · Public APIs are backed by the main extension implementation.
- TS tests → Extension entry: covers · TypeScript tests exercise activation and feature wiring.
- Py tests → Py helpers: covers · Python tests validate subprocess helpers and adapters.
- Build/release → Extension entry: packages · Build and release infrastructure packages the extension entrypoint.
- Build/release → Browser mode: packages · Separate builds target the browser variant as well.
