You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+81-34Lines changed: 81 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -1,57 +1,103 @@
1
-
# Python Environments and Package Manager (experimental)
1
+
# Python Environments (experimental)
2
2
3
3
## Overview
4
4
5
-
The Python Environments and Package Manager extension for VS Code helps you manage Python environments and packages using your preferred environment manager backed by its extensible APIs. This extension provides unique support to specify environments for specific files or whole Python folders or projects, including multi-root & mono-repos scenarios.
5
+
The Python Environments extension for VS Code helps you manage Python environments and packages using your preferred environment manager, backed by its extensible APIs. This extension provides unique support for specifying environments for specific files, entire Python folders, or projects, including multi-root and mono-repo scenarios. The core feature set includes:
6
6
7
-
> Note: This extension is in preview and its APIs and features are subject to change as the project continues to evolve.
7
+
- 🌐 Create, delete, and manage environments
8
+
- 📦 Install and uninstall packages within the selected environment
9
+
- ✅ Create activated terminals
10
+
- 🖌️ Add and create new Python projects
8
11
9
-
> Important: This extension currently requires the pre-release version of the Python extension (ms-python.python) to operate (version 2024.23.2025010901 or later).
12
+
> **Note:** This extension is in preview, and its APIs and features are subject to change as the project evolves.
13
+
14
+
> **Important:** This extension requires version `2024.23`, or later, of the Python extension (`ms-python.python`).
The "Python Projects" fold shows you all of the projects that are currently in your workspace and their selected environments. From this view you can add more files or folders as projects, select a new environment for your project, and manage your selected environments.
19
+
20
+
The "Environment Managers" fold shows you all of the environment managers that are available on your machine with all related environments nested below. From this view, you can create new environments, delete old environments, and manage packages.
This extension provides an Environments view, which can be accessed via the VS Code Activity Bar, where you can manage your Python environments. Here, you can create, delete, and switch between environments, as well as install and uninstall packages within the selected environment. It also provides APIs for extension developers to contribute their own environment managers.
26
+
The Python Environments panel provides an interface to create, delete and manage environments.
To simplify the environment creation process, you can use "Quick Create" to automatically create a new virtual environment using:
18
31
19
-
By default, the extension uses the `venv` environment manager. This default manager determines how environments are created, managed, and where packages are installed. However, users can change the default by setting the `python-envs.defaultEnvManager` to a different environment manager. The following environment managers are supported out of the box:
32
+
- Your default environment manager (e.g., `venv`)
33
+
- The latest Python version
34
+
- Workspace dependencies
20
35
21
-
| Id | name | Description |
36
+
For more control, you can create a custom environment where you can specify Python version, environment name, packages to be installed, and more!
37
+
38
+
The following environment managers are supported out of the box:
| ms-python.python:venv|`venv`| The default environment manager. It is a built-in environment manager provided by the Python standard library. |
24
43
| ms-python.python:system| System Installed Python | These are global Python installs on your system. These are typically installed with your OS, from [python.org](https://www.python.org/), or any other OS package manager. |
25
44
| ms-python.python:conda|`conda`| The [conda](https://conda.org) environment manager, as provided by conda distributions like [Anaconda Distribution](https://docs.anaconda.com/anaconda/) or [conda-forge](https://conda-forge.org/download/). |
26
45
27
-
The environment manager is responsible for specifying which package manager will be used by default to install and manage Python packages within the environment. This ensures that packages are managed consistently according to the preferred tools and settings of the chosen environment manager.
46
+
Environment managers are responsible for specifying which package manager will be used by default to install and manage Python packages within the environment (`venv` uses `pip` by default). This ensures that packages are managed consistently according to the preferred tools and settings of the chosen environment manager.
28
47
29
48
### Package Management
30
49
31
-
This extension provides a package view for you to manage, install and uninstall you Python packages in any particular environment. This extension provides APIs for extension developers to contribute package managers.
50
+
The extension also provides an interface to install and uninstall Python packages, and provides APIs for extension developers to contribute package managers of their choice.
32
51
33
-
The extension uses `pip` as the default package manager. You can change this by setting the `python-envs.defaultPackageManager` setting to a different package manager. The following are package managers supported out of the box:
52
+
The extension uses `pip` as the default package manager, but you can use the package manager of your choice using the `python-envs.defaultPackageManager` setting. The following are package managers supported out of the box:
| ms-python.python:pip|`pip`| Pip acts as the default package manager and it's typically built-in to Python. |
38
57
| ms-python.python:conda|`conda`| The [conda](https://conda.org) package manager, as provided by conda distributions like [Anaconda Distribution](https://docs.anaconda.com/anaconda/) or [conda-forge](https://conda-forge.org/download/). |
39
58
59
+
### Project Management
60
+
61
+
A "Python Project" is any file or folder that contains runnable Python code and needs its own environment. With the Python Environments extension, you can add files and folders as projects in your workspace and assign individual environments to them allowing you to run various projects more seamlessly.
62
+
63
+
Projects can be added via the Python Environments pane or in the File Explorer by right-clicking on the folder/file and selecting the "Add as Python Project" menu item.
64
+
65
+
There are a couple of ways that you can add a Python Project from the Python Environments panel:
66
+
67
+
| Name | Description |
68
+
| ----- | ---------- |
69
+
| Add Existing | Allows you to add an existing folder from the file explorer. |
70
+
| Auto find | Searches for folders that contain `pyproject.toml` or `setup.py` files |
71
+
72
+
## Command Reference
73
+
74
+
| Name | Description |
75
+
| -------- | ------------- |
76
+
| Python: Create Environment | Create a virtual environment using your preferred environment manager preconfigured with "Quick Create" or configured to your choices. |
77
+
| Python: Manage Packages | Install and uninstall packages in a given Python environment. |
78
+
| Python: Activate Environment in Current Terminal | Activates the currently opened terminal with a particular environment. |
79
+
| Python: Deactivate Environment in Current Terminal | Deactivates environment in currently opened terminal. |
80
+
| Python: Run as Task | Runs Python module as a task. |
| defaultEnvManager |`"ms-python.python:venv"`| The default environment manager used for creating and managing environments. |
45
-
| defaultPackageManager |`"ms-python.python:pip"`| The default package manager to use for installing and managing packages. This is often dictated by the default environment manager but can be customized. |
86
+
| defaultEnvManager |`"ms-python.python:venv"`| The default environment manager used for creating and managing environments. |
87
+
| defaultPackageManager |`"ms-python.python:pip"`| The default package manager to use for installing and managing packages. This is often dictated by the default environment manager but can be customized. |
46
88
| pythonProjects |`[]`| A list of Python workspaces, specified by the path, in which you can set particular environment and package managers. You can set information for a workspace as `[{"path": "/path/to/workspace", "envManager": "ms-python.python:venv", "packageManager": "ms-python.python:pip"]}`. |
47
-
| terminal.showActivateButton |`false`|[experimental] Show a button in the terminal to activate/deactivate the current environment for the terminal. This button is only shown if the active terminal is associated with a project that has an activatable environment. |
89
+
| terminal.showActivateButton |`false`| (experimental) Show a button in the terminal to activate/deactivate the current environment for the terminal. This button is only shown if the active terminal is associated with a project that has an activatable environment. |
90
+
| python-envs.terminal.autoActivationType |`command`| Specifies how the extension can activate an environment in a terminal. Utilizing Shell Startup requires changes to the shell script file and is only enabled for the following shells: zsh, fsh, pwsh, bash, cmd. When set to `command`, any shell can be activated. This setting applies only when terminals are created, so you will need to restart your terminals for it to take effect. To revert changes made during shellStartup, run `Python Envs: Revert Shell Startup Script Changes`.|
91
+
92
+
## Extensibility
48
93
49
-
## API Reference (proposed)
94
+
The Python Environments extension was built to provide a cohesive and user friendly experience with `venv` as the default. However, the extension is built with extensibility in mind so that any environment manager could build an extension using the supported APIs to plug-in and provide a seamless and incorporated experience for their users in VS Code.
95
+
96
+
### API Reference (proposed)
50
97
51
98
See [api.ts](https://github.com/microsoft/vscode-python-environments/blob/main/src/api.ts) for the full list of Extension APIs.
52
99
53
-
To consume these APIs you can look at the example here:
To consume these APIs you can look at the example here: [API Consumption Examples](https://github.com/microsoft/vscode-python-environments/blob/main/examples/README.md)
55
101
56
102
### Callable Commands
57
103
@@ -77,23 +123,24 @@ Create a new environment using any of the available environment managers. This c
This section provides an overview of how the Python extension interacts with the Python Environments extension and other tool-specific extensions. The Python Environments extension allows users to create, manage, and remove Python environments and packages. It also provides an API that other extensions can use to support environment management or consume it for running Python tools or projects.
83
130
84
131
Tools that may rely on these APIs in their own extensions include:
85
132
86
-
-**Debuggers** (e.g., `debugpy`)
87
-
-**Linters** (e.g., Pylint, Flake8, Mypy)
88
-
-**Formatters** (e.g., Black, autopep8)
89
-
-**Language Server extensions** (e.g., Pylance, Jedi)
90
-
-**Environment and Package Manager extensions** (e.g., Pixi, Conda, Hatch)
133
+
-**Debuggers** (e.g., `debugpy`)
134
+
-**Linters** (e.g., Pylint, Flake8, Mypy)
135
+
-**Formatters** (e.g., Black, autopep8)
136
+
-**Language Server extensions** (e.g., Pylance, Jedi)
137
+
-**Environment and Package Manager extensions** (e.g., Pixi, Conda, Hatch)
91
138
92
139
### API Dependency
93
140
94
141
The relationship between these extensions can be represented as follows:
Users who do not need to execute code or work in **Virtual Workspaces** can use the Python extension to access language features like hover, completion, and go-to definition. However, executing code (e.g., running a debugger, linter, or formatter), creating/modifying environments, or managing packages requires the Python Environments extension to enable these functionalities.
99
146
@@ -103,15 +150,15 @@ VS Code supports trust management, allowing extensions to function in either **t
In **trusted mode**, the Python Environments extension supports tasks like managing environments, installing/removing packages, and running tools. In **untrusted mode**, functionality is limited to language features, ensuring a secure and restricted environment.
109
156
110
157
## Contributing
111
158
112
159
This project welcomes contributions and suggestions. Most contributions require you to agree to a
113
160
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
114
-
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
161
+
the rights to use your contribution. For details, visit <https://cla.opensource.microsoft.com>.
115
162
116
163
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
117
164
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
## Questions, issues, feature requests, and contributions
125
172
126
-
-If you have a question about how to accomplish something with the extension, please [ask on our Discussions page](https://github.com/microsoft/vscode-python/discussions/categories/q-a).
127
-
-If you come across a problem with the extension, please [file an issue](https://github.com/microsoft/vscode-python).
128
-
-Contributions are always welcome! Please see our [contributing guide](https://github.com/Microsoft/vscode-python/blob/main/CONTRIBUTING.md) for more details.
129
-
-Any and all feedback is appreciated and welcome!
130
-
- If someone has already [filed an issue](https://github.com/Microsoft/vscode-python) that encompasses your feedback, please leave a 👍/👎 reaction on the issue.
131
-
- Otherwise please start a [new discussion](https://github.com/microsoft/vscode-python/discussions/categories/ideas).
132
-
-If you're interested in the development of the extension, you can read about our [development process](https://github.com/Microsoft/vscode-python/blob/main/CONTRIBUTING.md#development-process).
173
+
- If you have a question about how to accomplish something with the extension, please [ask on our Discussions page](https://github.com/microsoft/vscode-python/discussions/categories/q-a).
174
+
- If you come across a problem with the extension, please [file an issue](https://github.com/microsoft/vscode-python).
175
+
- Contributions are always welcome! Please see our [contributing guide](https://github.com/Microsoft/vscode-python/blob/main/CONTRIBUTING.md) for more details.
176
+
- Any and all feedback is appreciated and welcome!
177
+
- If someone has already [filed an issue](https://github.com/Microsoft/vscode-python) that encompasses your feedback, please leave a 👍/👎 reaction on the issue.
178
+
- Otherwise please start a [new discussion](https://github.com/microsoft/vscode-python/discussions/categories/ideas).
179
+
- If you're interested in the development of the extension, you can read about our [development process](https://github.com/Microsoft/vscode-python/blob/main/CONTRIBUTING.md#development-process).
133
180
134
181
## Data and telemetry
135
182
136
-
The Microsoft Python Extension for Visual Studio Code collects usage data and sends it to Microsoft to help improve our products and services. Read our [privacy statement](https://privacy.microsoft.com/privacystatement) to learn more. This extension respects the `telemetry.enableTelemetry` setting which you can learn more about at https://code.visualstudio.com/docs/supporting/faq#_how-to-disable-telemetry-reporting.
183
+
The Microsoft Python Extension for Visual Studio Code collects usage data and sends it to Microsoft to help improve our products and services. Read our [privacy statement](https://privacy.microsoft.com/privacystatement) to learn more. This extension respects the `telemetry.enableTelemetry` setting which you can learn more about at <https://code.visualstudio.com/docs/supporting/faq#_how-to-disable-telemetry-reporting>.
0 commit comments