Skip to content

Developper instructions

Florian Blanchet edited this page Apr 2, 2023 · 20 revisions

Setup

Clone

git clone https://github.com/NotANameServer/incipyt
cd incipyt

Setup virtual environment and incipyt package

Linux

python -m venv --upgrade-deps .env
source .env/bin/activate
python -m pip install -e ".[test]"

Windows

py -m venv --upgrade-deps .env
.\.env\Scripts\activate
python -m pip install -e ".[test]"

Note: To activate virtual environments in Windows PowerShell, script execution has to be enabled on your system. You can enable it with:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Setup pre-commit for formatter and linter

pre-commit install --install-hooks --overwrite

You can test pre-commit with pre-commit run --all-files. Also install pre-commit globally (pipx install pre-commit).

Optional: recommended .vscode/settings.json for Visual Studio Code

{
    "editor.formatOnSave": true,
    "git.allowForcePush": true,
    "git.confirmForcePush": false,
    "python.disableInstallationCheck": true,
    "python.formatting.blackPath": ".env/bin/black",
    "python.formatting.provider": "black",
    "python.linting.flake8CategorySeverity.W": "Error",
    "python.linting.flake8Enabled": true,
    "python.linting.flake8Path": ".env/bin/flake8heavened",
    "python.terminal.activateEnvInCurrentTerminal": true,
    "python.testing.pytestArgs": [
        "tests",
        "-vv",
        "--cov=incipyt",
        "--cov-report=xml",
    ],
    "python.testing.pytestEnabled": true,
    "python.testing.pytestPath": ".env/bin/pytest",
}

Optional: recommended .vscode/launch.json for Visual Studio Code

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug Tests",
            "type": "python",
            "request": "test",
            "env": {
                "PYTEST_ADDOPTS": "--no-cov"
            }
        }
    ]
}

Check & build

Run tests

# With coverage
python -m pytest -vv --cov=incipyt --cov-report=xml tests

# Without coverage
python -m pytest -vv tests

Run formatter and linter on all project files

python -m black incipyt
python -m flakeheaven lint incipyt

Build

python -m build --no-isolation

Contributing

Commit your changes using Conventional Commits

feat: project initialization

We decided to use pep517 pyproject.toml with flit, we decided to use
pre-commit to automate linting and stuff.

We decided to use flit over setuptools, poetry and pdm because it is
mostly pep517 and pep621 compatible (unless setuptools) and it just does
the job of building and publishing the package (unless poetry and pdm).

We decided to use pre-commit with a large range of linters to ease the
development between contributors. Among the "stuff" we enabled are: file
sanitizers (line endind, useless whitespaces, line line at end of file),
file checker (python, toml, yaml), linter and formatter (python) and
some security watchdogs (don't commit those private keys!).

We decided to use pytest over unittest, we just want to give that
framework a try. We decided to use the boring sphinx because nothing
else seems funny enough to us.

Closes #3