-
Notifications
You must be signed in to change notification settings - Fork 221
Add contributing guide to setup dev environment #470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
9e57805
a605db2
b9cbb89
295d2ff
a19fadc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Setup the environment | ||
|
||
1. Clone the repo: `git clone [email protected]:python-lsp/python-lsp-server.git` | ||
2. Create the virtual environment: `python3 -m venv .venv` | ||
3. Activate: `source .venv/bin/activate` | ||
4. Install an editable installation: `pip3 install -e .` | ||
staticf0x marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- This will ensure you'll see your edits immediately without reinstalling the project | ||
|
||
## Configure your editor | ||
|
||
In Sublime Text 4, open LSP-pylsp settings and change the path to the `pylsp` command: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if mentioning one preferred editor over others is a good idea because the setup and development workflow is completely different for each of them. I mean, I could write a guide for Spyder as well (which would be useful for our interested contributors) and it'd be another thing entirely. So, perhaps having a contributing guide per editor would be better? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand, I initially mentioned ST4 because making it use a custom pylsp path was very difficult, so I felt it was important. But yes, there's too many editors and IDEs to cover that it might not be a good idea to have it in the contributing guide.
That sounds like a good idea. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Or perhaps none at all? Surely, those who are able and willing to contribute will be able to configure their editor already. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the ST config in favor of a generic point of configuring the editor. |
||
|
||
```json | ||
{ | ||
"command": ["/home/user/projects/python-lsp-server/run", "-vvv", "--log-file", "pylsp.log"] | ||
} | ||
``` | ||
|
||
Option `-v` increases verbosity and `--log-file` will write all log messages | ||
into a file, which can be used for debugging. | ||
|
||
Running command `LSP: Troubleshoot server` you should now see the configured command, | ||
if not, then the configuration doesn't work as expected. | ||
|
||
To enabled plugins like `ruff`, you also need to point your editor to the correct | ||
`PYTHONPATH`: | ||
|
||
```json | ||
{ | ||
"command": ["/home/user/projects/python-lsp-server/run", "-vvv", "--log-file", "pylsp.log"], | ||
"env": { | ||
"PYTHONPATH": "/home/user/projects/python-lsp-server/.venv/lib/python3.11/site-packages", | ||
}, | ||
} | ||
``` | ||
|
||
## Trying out if it works | ||
|
||
Go to file `pylsp/python_lsp.py`, function `start_io_lang_server`, | ||
and on the first line of the function, add some logging: | ||
|
||
```py | ||
log.info("It works!") | ||
``` | ||
|
||
Save the file, restart the LSP server and you should see the log line: | ||
|
||
``` | ||
2023-10-12 16:46:38,320 CEST - INFO - pylsp._utils - It works! | ||
``` | ||
|
||
Now the project is setup in a way you can quickly iterate change you want to add. | ||
|
||
# Running tests | ||
|
||
1. Install runtime dependencies: `pip3 install .[all]` | ||
2. Install test dependencies: `pip3 install .[test]` | ||
staticf0x marked this conversation as resolved.
Show resolved
Hide resolved
|
||
3. Run `pytest`: `pytest -v` | ||
|
||
## Useful pytest options | ||
|
||
- To run a specific test file, use `pytest test/test_utils.py` | ||
- To run a specific test function within a test file, | ||
use `pytest test/test_utils.py::test_debounce` | ||
- To run tests matching a certain expression, use `pytest -k format` | ||
- To increase verbosity of pytest, use `pytest -v` or `pytest -vv` | ||
- To enter a debugger on failed tests, use `pytest --pdb` |
Uh oh!
There was an error while loading. Please reload this page.