Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 50 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ This extension provides an Environments view, which can be accessed via the VS C

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:

|Id| name |Description|
|---|----|--|
|ms-python.python:venv| `venv` |The default environment manager. It is a built-in environment manager provided by the Python standard library.|
|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. |
|ms-python.python:conda| `conda` | The [Anaconda](https://www.anaconda.com/) environment manager. |
| Id | name | Description |
| ----------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ms-python.python:venv | `venv` | The default environment manager. It is a built-in environment manager provided by the Python standard library. |
| 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. |
| ms-python.python:conda | `conda` | The [Anaconda](https://www.anaconda.com/) environment manager. |

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.

Expand All @@ -28,27 +28,58 @@ This extension provides a package view for you to manage, install and uninstall

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:

|Id| name |Description|
|---|----|--|
|ms-python.python:pip| `pip` | Pip acts as the default package manager and it's typically built-in to Python.|
|ms-python.python:conda| `conda` | The [Anaconda](https://www.anaconda.com/) environment manager. |
| Id | name | Description |
| ---------------------- | ------- | ------------------------------------------------------------------------------ |
| ms-python.python:pip | `pip` | Pip acts as the default package manager and it's typically built-in to Python. |
| ms-python.python:conda | `conda` | The [Anaconda](https://www.anaconda.com/) environment manager. |

## Settings Reference

| Setting (python-envs.) | Default | Description |
| ----- | ----- | -----|
| defaultEnvManager | `"ms-python.python:venv"` | The default environment manager used for creating and managing environments. |
| 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. |
| 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"]}`. |
| Setting (python-envs.) | Default | Description |
| ---------------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| defaultEnvManager | `"ms-python.python:venv"` | The default environment manager used for creating and managing environments. |
| 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. |
| 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"]}`. |

## API Reference (proposed)

## API Reference
See [api.ts](https://github.com/microsoft/vscode-python-environments/blob/main/src/api.ts) for the full list of Extension APIs.

See `src\api.ts` for the full list of APIs.
Consuming these APIs from your extension:

```typescript
let _extApi: PythonEnvironmentApi | undefined;
async function getEnvExtApi(): Promise<PythonEnvironmentApi> {
if (_extApi) {
return _extApi;
}
const extension = getExtension(ENVS_EXTENSION_ID);
if (!extension) {
throw new Error('Python Environments extension not found.');
}
if (extension?.isActive) {
_extApi = extension.exports as PythonEnvironmentApi;
return _extApi;
}

await extension.activate();

_extApi = extension.exports as PythonEnvironmentApi;
return _extApi;
}

export async function activate(context: ExtensionContext) {
const envApi = await getEnvExtApi();

// Get the environment for the workspace folder or global python if no workspace is open
const uri = workspace.workspaceFolders ? workspace.workspaceFolders[0].uri : undefined;
const env = await envApi.getEnvironment(uri);
}
```

## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

Expand All @@ -60,7 +91,6 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.


## Questions, issues, feature requests, and contributions

- 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).
Expand All @@ -77,7 +107,7 @@ The Microsoft Python Extension for Visual Studio Code collects usage data and se

## Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.
Any use of third-party trademarks or logos are subject to those third-party's policies.
24 changes: 11 additions & 13 deletions build/azure-pipeline.pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
trigger: none
pr: none

schedules:
- cron: '0 10 * * 1-5' # 10AM UTC (2AM PDT) MON-FRI (VS Code Pre-release builds at 9PM PDT)
displayName: Nightly Pre-Release Schedule
always: false # only run if there are source code changes
branches:
include:
- main
# schedules:
# - cron: '0 10 * * 1-5' # 10AM UTC (2AM PDT) MON-FRI (VS Code Pre-release builds at 9PM PDT)
# displayName: Nightly Pre-Release Schedule
# always: false # only run if there are source code changes
# branches:
# include:
# - main

resources:
repositories:
Expand All @@ -27,7 +27,8 @@ parameters:
extends:
template: azure-pipelines/extension/pre-release.yml@templates
parameters:
publishExtension: ${{ parameters.publishExtension }}
# publishExtension: ${{ parameters.publishExtension }}
publishExtension: false
ghCreateTag: false
standardizedVersioning: true
l10nSourcePaths: ./src
Expand Down Expand Up @@ -71,23 +72,20 @@ extends:

- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
versionSpec: '3.9'
addToPath: true
architecture: 'x64'
displayName: Select Python version

- script: npm ci
displayName: Install NPM dependencies

- script: python ./build/update_package_file.py
- script: python ./build/update_package_json.py
displayName: Update telemetry in package.json

- script: python ./build/update_ext_version.py --for-publishing
displayName: Update build number

- script: npx gulp prePublishBundle
displayName: Build

- bash: |
mkdir -p $(Build.SourcesDirectory)/python-env-tools/bin
chmod +x $(Build.SourcesDirectory)/python-env-tools/bin
Expand Down
49 changes: 35 additions & 14 deletions build/azure-pipeline.stable.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
trigger: none
# branches:
# include:
# - release*
# tags:
# include: ['*']
pr: none

resources:
Expand All @@ -26,10 +21,42 @@ extends:
l10nSourcePaths: ./src
publishExtension: ${{ parameters.publishExtension }}
ghCreateTag: true

buildPlatforms:
- name: Linux
vsceTarget: 'web'
- name: Linux
packageArch: arm64
vsceTarget: linux-arm64
- name: Linux
packageArch: arm
vsceTarget: linux-armhf
- name: Linux
packageArch: x64
vsceTarget: linux-x64
- name: Linux
packageArch: arm64
vsceTarget: alpine-arm64
- name: Linux
packageArch: x64
vsceTarget: alpine-x64
- name: MacOS
packageArch: arm64
vsceTarget: darwin-arm64
- name: MacOS
packageArch: x64
vsceTarget: darwin-x64
- name: Windows
packageArch: arm
vsceTarget: win32-arm64
- name: Windows
packageArch: x64
vsceTarget: win32-x64

buildSteps:
- task: NodeTool@0
inputs:
versionSpec: '18.17.0'
versionSpec: '20.18.0'
displayName: Select Node version

- task: UsePythonVersion@0
Expand All @@ -42,14 +69,8 @@ extends:
- script: npm ci
displayName: Install NPM dependencies

- script: python -m pip install -U pip
displayName: Upgrade pip

- script: python -m pip install wheel
displayName: Install wheel

- script: python -m pip install nox
displayName: Install wheel
- script: python ./build/update_package_json.py
displayName: Update telemetry in package.json

- script: python ./build/update_ext_version.py --release --for-publishing
displayName: Update build number
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
{
"command": "python-envs.createTerminal",
"group": "inline",
"when": "view == env-managers && viewItem =~ /.*pythonEnvironment.*/"
"when": "view == env-managers && viewItem =~ /.*pythonEnvironment.*activatable.*/"
},
{
"command": "python-envs.refreshPackages",
Expand Down Expand Up @@ -315,16 +315,16 @@
{
"command": "python-envs.set",
"group": "inline",
"when": "view == python-projects && viewItem == python-workspace"
"when": "view == python-projects && viewItem =~ /.*python-workspace.*/"
},
{
"command": "python-envs.reset",
"when": "view == python-projects && viewItem == python-workspace"
"when": "view == python-projects && viewItem =~ /.*python-workspace.*/"
},
{
"command": "python-envs.createTerminal",
"group": "inline",
"when": "view == python-projects && viewItem == python-workspace"
"when": "view == python-projects && viewItem =~ /.*python-workspace.*/"
}
],
"view/title": [
Expand Down
Loading
Loading