Skip to content

Commit fc9af86

Browse files
authored
Clean-up and bug fixes (#36)
1 parent 53d7804 commit fc9af86

File tree

13 files changed

+254
-115
lines changed

13 files changed

+254
-115
lines changed

README.md

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ This extension provides an Environments view, which can be accessed via the VS C
1414

1515
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:
1616

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

2323
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.
2424

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

2929
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:
3030

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

3636
## Settings Reference
3737

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

44+
## API Reference (proposed)
4445

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

47-
See `src\api.ts` for the full list of APIs.
48+
Consuming these APIs from your extension:
49+
50+
```typescript
51+
let _extApi: PythonEnvironmentApi | undefined;
52+
async function getEnvExtApi(): Promise<PythonEnvironmentApi> {
53+
if (_extApi) {
54+
return _extApi;
55+
}
56+
const extension = getExtension(ENVS_EXTENSION_ID);
57+
if (!extension) {
58+
throw new Error('Python Environments extension not found.');
59+
}
60+
if (extension?.isActive) {
61+
_extApi = extension.exports as PythonEnvironmentApi;
62+
return _extApi;
63+
}
64+
65+
await extension.activate();
66+
67+
_extApi = extension.exports as PythonEnvironmentApi;
68+
return _extApi;
69+
}
70+
71+
export async function activate(context: ExtensionContext) {
72+
const envApi = await getEnvExtApi();
73+
74+
// Get the environment for the workspace folder or global python if no workspace is open
75+
const uri = workspace.workspaceFolders ? workspace.workspaceFolders[0].uri : undefined;
76+
const env = await envApi.getEnvironment(uri);
77+
}
78+
```
4879

4980
## Contributing
5081

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

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

63-
6494
## Questions, issues, feature requests, and contributions
6595

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

78108
## Trademarks
79109

80-
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
110+
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
81111
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
82112
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
83-
Any use of third-party trademarks or logos are subject to those third-party's policies.
113+
Any use of third-party trademarks or logos are subject to those third-party's policies.

build/azure-pipeline.pre-release.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
trigger: none
33
pr: none
44

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

1313
resources:
1414
repositories:
@@ -27,7 +27,8 @@ parameters:
2727
extends:
2828
template: azure-pipelines/extension/pre-release.yml@templates
2929
parameters:
30-
publishExtension: ${{ parameters.publishExtension }}
30+
# publishExtension: ${{ parameters.publishExtension }}
31+
publishExtension: false
3132
ghCreateTag: false
3233
standardizedVersioning: true
3334
l10nSourcePaths: ./src
@@ -71,23 +72,20 @@ extends:
7172

7273
- task: UsePythonVersion@0
7374
inputs:
74-
versionSpec: '3.8'
75+
versionSpec: '3.9'
7576
addToPath: true
7677
architecture: 'x64'
7778
displayName: Select Python version
7879

7980
- script: npm ci
8081
displayName: Install NPM dependencies
8182

82-
- script: python ./build/update_package_file.py
83+
- script: python ./build/update_package_json.py
8384
displayName: Update telemetry in package.json
8485

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

88-
- script: npx gulp prePublishBundle
89-
displayName: Build
90-
9189
- bash: |
9290
mkdir -p $(Build.SourcesDirectory)/python-env-tools/bin
9391
chmod +x $(Build.SourcesDirectory)/python-env-tools/bin

build/azure-pipeline.stable.yml

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
trigger: none
2-
# branches:
3-
# include:
4-
# - release*
5-
# tags:
6-
# include: ['*']
72
pr: none
83

94
resources:
@@ -26,10 +21,42 @@ extends:
2621
l10nSourcePaths: ./src
2722
publishExtension: ${{ parameters.publishExtension }}
2823
ghCreateTag: true
24+
25+
buildPlatforms:
26+
- name: Linux
27+
vsceTarget: 'web'
28+
- name: Linux
29+
packageArch: arm64
30+
vsceTarget: linux-arm64
31+
- name: Linux
32+
packageArch: arm
33+
vsceTarget: linux-armhf
34+
- name: Linux
35+
packageArch: x64
36+
vsceTarget: linux-x64
37+
- name: Linux
38+
packageArch: arm64
39+
vsceTarget: alpine-arm64
40+
- name: Linux
41+
packageArch: x64
42+
vsceTarget: alpine-x64
43+
- name: MacOS
44+
packageArch: arm64
45+
vsceTarget: darwin-arm64
46+
- name: MacOS
47+
packageArch: x64
48+
vsceTarget: darwin-x64
49+
- name: Windows
50+
packageArch: arm
51+
vsceTarget: win32-arm64
52+
- name: Windows
53+
packageArch: x64
54+
vsceTarget: win32-x64
55+
2956
buildSteps:
3057
- task: NodeTool@0
3158
inputs:
32-
versionSpec: '18.17.0'
59+
versionSpec: '20.18.0'
3360
displayName: Select Node version
3461

3562
- task: UsePythonVersion@0
@@ -42,14 +69,8 @@ extends:
4269
- script: npm ci
4370
displayName: Install NPM dependencies
4471

45-
- script: python -m pip install -U pip
46-
displayName: Upgrade pip
47-
48-
- script: python -m pip install wheel
49-
displayName: Install wheel
50-
51-
- script: python -m pip install nox
52-
displayName: Install wheel
72+
- script: python ./build/update_package_json.py
73+
displayName: Update telemetry in package.json
5374

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

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@
286286
{
287287
"command": "python-envs.createTerminal",
288288
"group": "inline",
289-
"when": "view == env-managers && viewItem =~ /.*pythonEnvironment.*/"
289+
"when": "view == env-managers && viewItem =~ /.*pythonEnvironment.*activatable.*/"
290290
},
291291
{
292292
"command": "python-envs.refreshPackages",
@@ -315,16 +315,16 @@
315315
{
316316
"command": "python-envs.set",
317317
"group": "inline",
318-
"when": "view == python-projects && viewItem == python-workspace"
318+
"when": "view == python-projects && viewItem =~ /.*python-workspace.*/"
319319
},
320320
{
321321
"command": "python-envs.reset",
322-
"when": "view == python-projects && viewItem == python-workspace"
322+
"when": "view == python-projects && viewItem =~ /.*python-workspace.*/"
323323
},
324324
{
325325
"command": "python-envs.createTerminal",
326326
"group": "inline",
327-
"when": "view == python-projects && viewItem == python-workspace"
327+
"when": "view == python-projects && viewItem =~ /.*python-workspace.*/"
328328
}
329329
],
330330
"view/title": [

0 commit comments

Comments
 (0)