From 6915d55c33677a660d8525c165df041a84798dec Mon Sep 17 00:00:00 2001 From: Frederik Hennig <frederik.hennig@fau.de> Date: Wed, 24 Jul 2024 17:52:45 +0200 Subject: [PATCH] Fix version string in docs. Update CONTRIBUTING. --- .gitignore | 3 +-- CONTRIBUTING.md | 28 +++++++++++++--------------- docs/source/conf.py | 11 ++++++++++- git-hooks/pre-commit | 4 ++-- pyproject.toml | 4 +++- 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 117c817..65c4064 100644 --- a/.gitignore +++ b/.gitignore @@ -7,9 +7,8 @@ **/build -# pdm dev environment +# dev environment **/.venv -.pdm-python # build artifacts dist diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8e11264..ef8905c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,37 +20,35 @@ a local clone of your fork. ### Set up your dev environment -`pystencils-sfg` uses [`pdm`](https://pdm-project.org) for managing a virtual development environment. -Install `pdm` through your system's package manager and run `pdm sync` in your cloned project directory. -It will set up a virtual environment in the subfolder `.venv`, installing all project dependencies into it. -The `pystencils-sfg` package itself is also installed in editable mode. -You can activate the virtual environment using `eval $(pdm venv activate)`. +Create a virtual environment using either `venv` or `virtualenv` and install the pystencils-sfg source tree +into it using an editable install, e.g. by running the following commands in the `pystencils-sfg` project root directory: + +```bash +python -m virtualenv .venv +source .venv/bin/activate +pip install -e . +``` ### Code Style and Type Checking To contribute, please adhere to the Python code style set by [PEP 8](https://peps.python.org/pep-0008/). -It is recommended that you use the [black](https://pypi.org/project/black/) formatter to format your source files. -Use flake8 (installed in the `pdm` virtual environment) to check your code style: +For consistency, format all your source files using the [black](https://pypi.org/project/black/) formatter. +Use flake8 to check your code style: ```shell -pdm run flake8 src/pystencilssfg -# or, if .venv is activated flake8 src/pystencilssfg ``` -Further, `pystencils-sfg` takes a rigorous approach to correct static typing. +Further, `pystencils-sfg` is being fully type-checked using [MyPy](https://www.mypy-lang.org/). All submitted code should contain type annotations ([PEP 484](https://peps.python.org/pep-0484/)) and must be correctly statically typed. -To check types, we use [MyPy](https://www.mypy-lang.org/), which is automatically installed in the dev environment -and can be invoked as +Before each commit, check your types by calling ```shell -pdm run mypy src/pystencilssfg -# or, if .venv is activated mypy src/pystencilssfg ``` Both `flake8` and `mypy` are also run in the integration pipeline. -It is furthermore recommended to run both checkers as a git pre-commit hook. +You can automate the code quality checks by running them via a git pre-commit hook. Such a hook can be installed using the [`install_git_hooks.sh`](install_git_hooks.sh) script located at the project root. diff --git a/docs/source/conf.py b/docs/source/conf.py index 8a8d28d..84c2b77 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,3 +1,6 @@ +from pystencilssfg import __version__ as sfg_version +from packaging.version import Version + # Configuration file for the Sphinx documentation builder. # # For the full list of built-in configuration values, see the documentation: @@ -9,7 +12,13 @@ project = "pystencils-sfg" copyright = "2024, Frederik Hennig" author = "Frederik Hennig" -release = "0.0a" + +parsed_version = Version(sfg_version) + +version = ".".join([parsed_version.public]) +release = sfg_version + +html_title = f"pystencils-sfg v{version} Documentation" # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/git-hooks/pre-commit b/git-hooks/pre-commit index 9016685..aaa96f6 100755 --- a/git-hooks/pre-commit +++ b/git-hooks/pre-commit @@ -1,7 +1,7 @@ #!/bin/bash echo "[Pre-Commit] Checking code style" -pdm run flake8 src/pystencilssfg +flake8 src/pystencilssfg status=$? if [ ${status} != 0 ]; then @@ -11,7 +11,7 @@ else fi echo "[Pre-Commit] Checking types" -pdm run mypy src/pystencilssfg +mypy src/pystencilssfg status=$? if [ ${status} != 0 ]; then exit 1 diff --git a/pyproject.toml b/pyproject.toml index 5b4e66b..6812c55 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,6 +29,7 @@ interactive = [ testing = [ "flake8>=6.1.0", "mypy>=1.7.0", + "black" ] docs = [ "sphinx", @@ -36,7 +37,8 @@ docs = [ "myst-parser", "sphinx_design", "sphinx_autodoc_typehints", - "sphinx-copybutton" + "sphinx-copybutton", + "packaging" ] [tool.versioneer] -- GitLab