-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Project's development setup described (#297)
- Loading branch information
1 parent
70652f0
commit 70ce604
Showing
10 changed files
with
148 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"recommendations": [ | ||
"ms-python.black-formatter", | ||
"ms-python.flake8", | ||
"ms-python.isort", | ||
"ms-python.mypy-type-checker", | ||
"ms-python.python", | ||
"ms-python.vscode-pylance" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Development Environment | ||
|
||
## Project Setup | ||
|
||
### System Requirements | ||
|
||
- CPython >= 3.11.0 | ||
- [PDM](https://pdm-project.org/latest/#installation) >= 2.15 | ||
|
||
### Virtual environment | ||
|
||
#### Option 1: Use an already created virtual environment via `pyenv-virtualenv` | ||
|
||
```sh | ||
# Create the virtual environment | ||
pyenv virtualenv 3.11 easynetwork-3.11 | ||
|
||
# Set the local python (3.12 and upward are still needed for tox) | ||
pyenv local "easynetwork-3.11" 3.12 | ||
|
||
# Tell pdm to use your virtualenv | ||
pdm use -f $VIRTUAL_ENV | ||
# -> Using Python interpreter: /path/to/.pyenv/versions/3.11.x/envs/easynetwork-3.11/bin/python3 (3.11) | ||
``` | ||
|
||
#### Option 2: Let `pdm` create a `.venv` folder | ||
|
||
0. For the `pyenv` users, set the local python : | ||
```sh | ||
pyenv local 3.11 3.12 | ||
``` | ||
|
||
1. Create the virtual environment : | ||
```sh | ||
# Creates the virtual environment ( in .venv directory ) | ||
pdm venv create 3.11 | ||
|
||
# Tell pdm to use this virtualenv | ||
pdm use --venv in-project | ||
``` | ||
|
||
2. Activate the virtual environment in the current shell using either : | ||
- the [manual way](https://docs.python.org/3.11/library/venv.html#how-venvs-work) | ||
- the [pdm venv CLI tool](https://pdm-project.org/latest/usage/venv/#activate-a-virtualenv) | ||
|
||
### Installation | ||
|
||
1. Install the project with its dependencies and development tools : | ||
```sh | ||
pdm install -G:all | ||
``` | ||
|
||
2. If it is a clone of the `git` project, run : | ||
```sh | ||
pre-commit install | ||
``` | ||
|
||
3. Check the installation : | ||
```sh | ||
# Run pre-commit hooks | ||
pre-commit run --all-files | ||
|
||
# Run mypy against all the project | ||
tox run -q -f mypy | ||
``` | ||
|
||
### Configure the IDE | ||
|
||
#### Visual Studio Code | ||
|
||
1. The recommended extensions are in [.vscode/extensions.json](.vscode/extensions.json) | ||
|
||
2. Copy [.vscode/settings.example.json](.vscode/settings.example.json) to `.vscode/settings.json` | ||
|
||
3. (Optional) To enable VS code's integrated testing tool, add this in your `settings.json`: | ||
```json | ||
{ | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true, | ||
"python.testing.pytestArgs": [ | ||
"-n", | ||
"auto" | ||
] | ||
} | ||
``` | ||
> :warning: **NEVER** run all the test suite with VS code integrated testing tool ! There are 8000+ tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[python] | ||
use_venv = true | ||
|
||
[venv] | ||
backend = "venv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from __future__ import annotations | ||
|
||
from collections.abc import Generator | ||
|
||
import pytest | ||
|
||
|
||
@pytest.hookimpl(wrapper=True) | ||
def pytest_xdist_auto_num_workers(config: pytest.Config) -> Generator[None, int, int]: | ||
"""determine how many workers to use based on how many tests were selected in the test explorer""" | ||
num_workers = yield | ||
if "vscode_pytest" in config.option.plugins: | ||
nb_launched_tests = len(config.option.file_or_dir) | ||
if nb_launched_tests == 1: | ||
# "0" means no workers | ||
return 0 | ||
return min(num_workers, nb_launched_tests) | ||
return num_workers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters