Skip to content

Latest commit

 

History

History
106 lines (70 loc) · 2.28 KB

File metadata and controls

106 lines (70 loc) · 2.28 KB

Contributing to Pglet for Python

Thank you for your interest in contributing to Pglet!

Clone repo

git clone https://github.com/pglet/pglet-python

Install PDM

Windows

(Invoke-WebRequest -Uri https://raw.githubusercontent.com/pdm-project/pdm/main/install-pdm.py -UseBasicParsing).Content | python -

Enable PEP 582:

pdm --pep582

Run refreshenv after installing PDM on Windows or restart terminal.

macOS

brew install pdm

Enable PEP 582:

pdm --pep582 >> ~/.zprofile

Restart the terminal session to take effect.

Install dependencies

To install all Pglet dependencies and enable the project as editable package run:

pdm install

Check the installation

Run "counter" example:

python3 examples/counter.py

During the first run Pglet Server will be downloaded from GitHub releases to $HOME/.pglet/bin directory and started from there. The version of Pglet Server to download is taken from PGLET_VERSION variable in appveyor.yml in the root of repository.

You should get a new browser window opened with "counter" web app running.

Running tests

Pytest should be run with pdm run:

pdm run pytest

Code formatting

The project uses Black formatting style. All .py files in a PR must be black-formatted.

IDE-specific Black integration guides:

Sort imports on Save

VS Code includes "isort" by default.

Add the following to user's settings.json :

"[python]": {
    "editor.codeActionsOnSave": {
        "source.organizeImports": true
    }
},
"python.sortImports.args": [
    "--trailing-comma",
    "--use-parentheses",
    "--line-width",
    "88",
    "--multi-line",
    "3",
    "--float-to-top"
],

All isort command line options can be found here.

pre-commit

pre-commit is a dev dependency of Pglet and is automatically installed by pdm install. To install the pre-commit hooks run: pre-commit install. Once installed, everytime you commit, pre-commit will run the configured hooks against changed files.