Skip to content

Commit f9391e0

Browse files
authored
Move contribution guidelines to the wiki
Makes for easier editing by the rest of the team.
1 parent 03e91e0 commit f9391e0

1 file changed

Lines changed: 1 addition & 359 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 359 deletions
Original file line numberDiff line numberDiff line change
@@ -1,359 +1 @@
1-
# Contributing to the Python extension for Visual Studio Code
2-
3-
---
4-
5-
- [![codecov](https://codecov.io/gh/microsoft/vscode-python/branch/main/graph/badge.svg)](https://codecov.io/gh/microsoft/vscode-python)
6-
- [Development build](https://pvsc.blob.core.windows.net/extension-builds/ms-python-insiders.vsix)
7-
8-
---
9-
10-
The following projects have their own repositories:
11-
12-
- [Pylance](https://github.com/microsoft/pylance-release)
13-
- [debugpy](https://github.com/microsoft/debugpy)
14-
- [Jupyter](https://github.com/microsoft/vscode-jupyter)
15-
- [Microsoft Python Language Server](https://github.com/Microsoft/python-language-server)
16-
17-
## Contributing a pull request
18-
19-
### Prerequisites
20-
21-
1. [Node.js](https://nodejs.org/) 12.20
22-
1. [Python](https://www.python.org/) 2.7 or later
23-
1. Windows, macOS, or Linux
24-
1. [Visual Studio Code](https://code.visualstudio.com/)
25-
1. The following VS Code extensions:
26-
- [ESlint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
27-
- [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
28-
- [EditorConfig for VS Code](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig)
29-
1. Have an issue which has a "needs PR" label (feel free to indicate you would like to provide a PR for the issue so others don't work on it as well)
30-
31-
### Setup
32-
33-
```shell
34-
git clone https://github.com/microsoft/vscode-python
35-
cd vscode-python
36-
npm ci
37-
python3 -m venv .venv
38-
# Activate the virtual environment as appropriate for your shell, For example, on bash it's ...
39-
source .venv/bin/activate
40-
# The Python code in the extension is formatted using Black.
41-
python3 -m pip install black
42-
# Install Python dependencies using `python3`.
43-
# If you want to use a different interpreter then specify it in the
44-
# CI_PYTHON_PATH environment variable.
45-
npx gulp installPythonLibs
46-
```
47-
48-
If you see warnings that `The engine "vscode" appears to be invalid.`, you can ignore these.
49-
50-
### Incremental Build
51-
52-
Run the `Compile` build task from the [Run Build Task...](https://code.visualstudio.com/docs/editor/tasks) command picker (short cut `CTRL+SHIFT+B` or `⇧⌘B`). This will leave build task running in the background and which will re-run as files are edited and saved. You can see the output from either task in the Terminal panel (use the selector to choose which output to look at).
53-
54-
You can also compile from the command-line. For a full compile you can use:
55-
56-
```shell
57-
npx gulp prePublishNonBundle
58-
```
59-
60-
For incremental builds you can use the following commands depending on your needs:
61-
62-
```shell
63-
npm run compile
64-
```
65-
66-
Sometimes you will need to run `npm run clean` and even `rm -r out`.
67-
This is especially true if you have added or removed files.
68-
69-
### Errors and Warnings
70-
71-
TypeScript errors and warnings will be displayed in the `Problems` window of Visual Studio Code.
72-
73-
### Run dev build and validate your changes
74-
75-
To test changes, open the `vscode-python` folder in VSCode, and select the workspace titled `vscode-python`.
76-
Then, open the debug panel by clicking the `Run and Debug` icon on the sidebar, select the `Extension`
77-
option from the top menu, and click start. A new window will launch with the title
78-
`[Extension Development Host]`.
79-
80-
### Running Unit Tests
81-
82-
Note: Unit tests are those in files with extension `.unit.test.ts`.
83-
84-
1. Make sure you have compiled all code (done automatically when using incremental building)
85-
1. Ensure you have disabled breaking into 'Uncaught Exceptions' when running the Unit Tests
86-
1. For the linters and formatters tests to pass successfully, you will need to have those corresponding Python libraries installed locally
87-
1. Run the Tests via the `Unit Tests` launch option.
88-
89-
You can also run them from the command-line (after compiling):
90-
91-
```shell
92-
npm run test:unittests # runs all unit tests
93-
npm run test:unittests -- --grep='<NAME-OF-SUITE>'
94-
```
95-
96-
_To run only a specific test suite for unit tests:_
97-
Alter the `launch.json` file in the `"Debug Unit Tests"` section by setting the `grep` field:
98-
99-
```js
100-
"args": [
101-
"--timeout=60000",
102-
"--grep", "<suite name>"
103-
],
104-
```
105-
106-
...this will only run the suite with the tests you care about during a test run (be sure to set the debugger to run the `Debug Unit Tests` launcher).
107-
108-
### Running Functional Tests
109-
110-
Functional tests are those in files with extension `.functional.test.ts`.
111-
These tests are similar to system tests in scope, but are run like unit tests.
112-
113-
You can run functional tests in a similar way to that for unit tests:
114-
115-
- via the "Functional Tests" launch option, or
116-
- on the command line via `npm run test:functional`
117-
118-
### Running System Tests
119-
120-
Note: System tests are those in files with extension `.test*.ts` but which are neither `.functional.test.ts` nor `.unit.test.ts`.
121-
122-
1. Make sure you have compiled all code (done automatically when using incremental building)
123-
1. Ensure you have disabled breaking into 'Uncaught Exceptions' when running the Unit Tests
124-
1. For the linters and formatters tests to pass successfully, you will need to have those corresponding Python libraries installed locally by using the `./requirements.txt` and `build/test-requirements.txt` files
125-
1. Run the tests via `npm run` or the Debugger launch options (you can "Start Without Debugging").
126-
1. **Note** you will be running tests under the default Python interpreter for the system.
127-
128-
You can also run the tests from the command-line (after compiling):
129-
130-
```shell
131-
npm run testSingleWorkspace # will launch the VSC UI
132-
npm run testMultiWorkspace # will launch the VSC UI
133-
```
134-
135-
#### Customising the Test Run
136-
137-
If you want to change which tests are run or which version of Python is used,
138-
you can do this by setting environment variables. The same variables work when
139-
running from the command line or launching from within VSCode, though the
140-
mechanism used to specify them changes a little.
141-
142-
- Setting `CI_PYTHON_PATH` lets you change the version of python the tests are executed with
143-
- Setting `VSC_PYTHON_CI_TEST_GREP` lets you filter the tests by name
144-
145-
_`CI_PYTHON_PATH`_
146-
147-
In some tests a Python executable is actually run. The default executable is
148-
`python` (for now). Unless you've run the tests inside a virtual environment,
149-
this will almost always mean Python 2 is used, which probably isn't what you
150-
want.
151-
152-
By setting the `CI_PYTHON_PATH` environment variable you can
153-
control the exact Python executable that gets used. If the executable
154-
you specify isn't on `$PATH` then be sure to use an absolute path.
155-
156-
This is also the mechanism for testing against other versions of Python.
157-
158-
_`VSC_PYTHON_CI_TEST_GREP`_
159-
160-
This environment variable allows providing a regular expression which will
161-
be matched against suite and test "names" to be run. By default all tests
162-
are run.
163-
164-
For example, to run only the tests in the `Sorting` suite (from
165-
[`src/test/format/extension.sort.test.ts`](https://github.com/Microsoft/vscode-python/blob/84f9c7a174111/src/test/format/extension.sort.test.ts))
166-
you would set the value to `Sorting`. To run the `ProcessService` and
167-
`ProcessService Observable` tests which relate to `stderr` handling, you might
168-
use the value `ProcessService.*stderr`.
169-
170-
Be sure to escape any grep-sensitive characters in your suite name.
171-
172-
In some rare cases in the "system" tests the `VSC_PYTHON_CI_TEST_GREP`
173-
environment variable is ignored. If that happens then you will need to
174-
temporarily modify the `const grep =` line in
175-
[`src/test/index.ts`](https://github.com/Microsoft/vscode-python/blob/84f9c7a174111/src/test/index.ts#L64).
176-
177-
_Launching from VSCode_
178-
179-
In order to set environment variables when launching the tests from VSCode you
180-
should edit the `launch.json` file. For example you can add the following to the
181-
appropriate configuration you want to run to change the interpreter used during
182-
testing:
183-
184-
```js
185-
"env": {
186-
"CI_PYTHON_PATH": "/absolute/path/to/interpreter/of/choice/python"
187-
}
188-
```
189-
190-
_On the command line_
191-
192-
The mechanism to set environment variables on the command line will vary based
193-
on your system, however most systems support a syntax like the following for
194-
setting a single variable for a subprocess:
195-
196-
```shell
197-
VSC_PYTHON_CI_TEST_GREP=Sorting npm run testSingleWorkspace
198-
```
199-
200-
### Testing Python Scripts
201-
202-
The extension has a number of scripts in ./pythonFiles. Tests for these
203-
scripts are found in ./pythonFiles/tests. To run those tests:
204-
205-
- `python2.7 pythonFiles/tests/run_all.py`
206-
- `python3 -m pythonFiles.tests`
207-
208-
By default, functional tests are included. To exclude them:
209-
210-
`python3 -m pythonFiles.tests --no-functional`
211-
212-
To run only the functional tests:
213-
214-
`python3 -m pythonFiles.tests --functional`
215-
216-
### Standard Debugging
217-
218-
Clone the repo into any directory, open that directory in VSCode, and use the `Extension` launch option within VSCode.
219-
220-
### Debugging the Python Extension Debugger
221-
222-
The easiest way to debug the Python Debugger (in our opinion) is to clone this git repo directory into [your](https://code.visualstudio.com/docs/extensions/install-extension#_your-extensions-folder) extensions directory.
223-
From there use the `Extension + Debugger` launch option.
224-
225-
### Coding Standards
226-
227-
Information on our coding standards can be found [here](https://github.com/Microsoft/vscode-python/blob/main/CODING_STANDARDS.md).
228-
We have CI tests to ensure the code committed will adhere to the above coding standards. \*You can run this locally by executing the command `npx gulp precommit` or use the `precommit` Task.
229-
230-
Messages displayed to the user must be localized using/created constants from/in the [localize.ts](https://github.com/Microsoft/vscode-python/blob/main/src/client/common/utils/localize.ts) file.
231-
232-
## Development process
233-
234-
To effectively contribute to this extension, it helps to know how its
235-
development process works. That way you know not only why the
236-
project maintainers do what they do to keep this project running
237-
smoothly, but it allows you to help out by noticing when a step is
238-
missed or to learn in case someday you become a project maintainer as
239-
well!
240-
241-
### Helping others
242-
243-
First and foremost, we try to be helpful to users of the extension.
244-
We monitor
245-
[Stack Overflow questions](https://stackoverflow.com/questions/tagged/visual-studio-code+python)
246-
to see where people might need help. We also try to respond to all
247-
issues in some way in a timely manner (typically in less than one
248-
business day, definitely no more than a week). We also answer
249-
questions that reach us in other ways, e.g. Twitter.
250-
251-
For pull requests, we aim to review any externally contributed PR no later
252-
than the next sprint from when it was submitted (see
253-
[Release Cycle](#release-cycle) below for our sprint schedule).
254-
255-
### Release cycle
256-
257-
Planning is done as one week sprints. We start a sprint every Thursday.
258-
All [P0](https://github.com/Microsoft/vscode-python/labels/P0) issues are expected
259-
to be fixed in the current sprint, else the next release will be blocked.
260-
[P1](https://github.com/Microsoft/vscode-python/labels/P1) issues are a
261-
top-priority and we try to close before the next release. All other issues are
262-
considered best-effort for that sprint.
263-
264-
The extension aims to do a new release once a month. A
265-
[release plan](https://github.com/Microsoft/vscode-python/labels/release%20plan)
266-
is created for each release to help track anything that requires a
267-
person to do (long-term this project aims to automate as much of the
268-
development process as possible).
269-
270-
All development is actively done in the `main` branch of the
271-
repository. This allows us to have a
272-
[development build](#development-build) which is expected to be stable at
273-
all times. Once we reach a release candidate, it becomes
274-
our [release branch](https://github.com/microsoft/vscode-python/branches).
275-
At that point only what is in the release branch will make it into the next
276-
release.
277-
278-
### Issue triaging
279-
280-
#### Classifying issues
281-
282-
To help actively track what stage
283-
[issues](https://github.com/Microsoft/vscode-python/issues)
284-
are at, various labels are used. The following label types are expected to
285-
be set on all open issues (otherwise the issue is not considered triaged):
286-
287-
1. `needs`/`triage`/`classify`
288-
1. `feature`
289-
1. `type`
290-
291-
These labels cover what is blocking the issue from closing, what is affected by
292-
the issue, and what kind of issue it is. (The `feature` label should be `feature-*` if the issue doesn't fit into any other `feature` label appropriately.)
293-
294-
It is also very important to make the title accurate. People often write very brief, quick titles or ones that describe what they think the problem is. By updating the title to be appropriately descriptive for what _you_ think the issue is, you not only make finding older issues easier, but you also help make sure that you and the original reporter agree on what the issue is.
295-
296-
#### Post-classification
297-
298-
Once an issue has been appropriately classified, there are two keys ways to help out. One is to go through open issues that
299-
have a merged fix and verify that the fix did in fact work. The other is to try to fix issues marked as `needs PR`.
300-
301-
### Pull requests
302-
303-
Key details that all pull requests are expected to handle should be
304-
in the [pull request template](https://github.com/Microsoft/vscode-python/blob/main/.github/PULL_REQUEST_TEMPLATE.md). We do expect CI to be passing for a pull request before we will consider merging it.
305-
306-
### Versioning
307-
308-
Starting in 2018, the extension switched to
309-
[calendar versioning](http://calver.org/) since the extension
310-
auto-updates and thus there is no need to track its version
311-
number for backwards-compatibility. In 2020, the extension switched to
312-
having the the major version be the year of release, the minor version the
313-
release count for that year, and the build number is a number that increments
314-
for every build.
315-
For example the first release made in 2020 is `2020.1.<build number>`.
316-
317-
## Releasing
318-
319-
Overall steps for releasing are covered in the
320-
[release plan](https://github.com/Microsoft/vscode-python/labels/release%20plan)
321-
([template](https://github.com/Microsoft/vscode-python/blob/main/.github/release_plan.md)).
322-
323-
### Building a release
324-
325-
To create a release _build_, follow the steps outlined in the [release plan](https://github.com/Microsoft/vscode-python/labels/release%20plan) (which has a [template](https://github.com/Microsoft/vscode-python/blob/main/.github/release_plan.md)).
326-
327-
## Local Build
328-
329-
Steps to build the extension on your machine once you've cloned the repo:
330-
331-
```bash
332-
> npm install -g vsce
333-
# Perform the next steps in the vscode-python folder.
334-
> npm ci
335-
> python3 -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade -r requirements.txt
336-
# For python 3.6 and lower use this command to install the debugger
337-
> python3 -m pip --disable-pip-version-check install -t ./pythonFiles/lib/python --no-cache-dir --implementation py --no-deps --upgrade --pre debugpy
338-
# For python 3.7 and greater use this command to install the debugger
339-
> python3 -m pip --disable-pip-version-check install -r build/debugger-install-requirements.txt
340-
> python3 ./pythonFiles/install_debugpy.py
341-
> npm run clean
342-
> npm run package # This step takes around 10 minutes.
343-
```
344-
345-
Resulting in a `ms-python-insiders.vsix` file in your `vscode-python` folder.
346-
347-
⚠️ If you made changes to `package.json`, run `npm install` (instead of `npm ci`) to update `package-lock.json` and install dependencies all at once.
348-
349-
## Development Build
350-
351-
If you would like to use the latest version of the extension as committed to `main` that has passed our test suite, then you may set the `"python.insidersChannel"` setting to `"daily"` or `"weekly"` based on how often you would like the extension to check for updates.
352-
353-
You may also download and install the extension manually from the following
354-
[location](https://pvsc.blob.core.windows.net/extension-builds/ms-python-insiders.vsix).
355-
Once you have downloaded the
356-
[ms-python-insiders.vsix](https://pvsc.blob.core.windows.net/extension-builds/ms-python-insiders.vsix)
357-
file, please follow the instructions on
358-
[this page](https://code.visualstudio.com/docs/editor/extension-gallery#_install-from-a-vsix)
359-
to install the extension. Do note that the manual install will not automatically update to newer builds unless you set the `"python.insidersChannel"` setting (it will get replaced with released versions from the Marketplace once they are newer than the version install manually).
1+
Please see the [Contributing page](https://github.com/microsoft/vscode-python/wiki/Contributing) in our wiki on how to contribute to this project.

0 commit comments

Comments
 (0)