This is short summary about how to setup the development environment
- Install
pyenv
and install your preferred Python version - Install and activate virtual environment in your working directory
python -m venv .venv
source .venv/bin/activate
- Update
pip
and install required Python tools defined inrequirements-dev.txt
:
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
The previous installation steps can be executed with the help of this script. The script can be used in the following way:
$ ./bin/create_python_env.sh 3.10.13
$ source .venv-3.10.13/bin/activate
(.venv-3.10.13) $
Please note:
- Install
pyenv
before use of this script - All dependencies will be installed (both for development and for documentation)
- The new virtual Python environment needs to be activated in the user shell too
The unit tests can be executed with pytest
:
pytest
The coverage can be also measured for unit tests:
pytest --cov=src --cov=test --cov-report=html
The HTML report will be generated at ./htmlcov
directory.
The package is checked with pylint
in the following way:
pylint src/diskinfo/*.py test/*.py
Its configuration options can be found pyproject.toml
file.
The setuptools
is used to create Python distribution package to PyPI. All package parameters are specified in
pyproject.toml
file. The package can be created in dist
directory:
python -m build
The new package can be uploaded to PyPI with twine
:
twine upload --verbose dist/*
NOTE: The distribution package will be built and published to PyPI automatically when a new github release created!
During the development this package can be installed locally:
pip install -e .
This project is using sphinx
to generate documentation on readthedocs.io. The
github repository is connected to readthedocs.io and when a new commit is
created in github, it will trigger documentation update on readthedocs.io side.
The documentation can be built and tested locally:
cd docs
pip install -r requirements-docs.txt
make html
The HTML documentation will be created in ./docs/build/html
folder.
NOTE: Many times the browsers do not display new version of documentation (because of caching?). You may try to reload the page ignoring browser cache (e.g. CTRL + SHIFT + R).
The project implemented the following GitHub workflows:
-
Unit test and lint execution (
test.yml
). A commit triggers this action:- executes unit test on
ubuntu-latest
OS and on Python versions3.8
,3.9
,3.10
,3.11
,3.12
- executes
pylint
- generates coverage data and upload it to codecov.io
- executes unit test on
-
Publish Python distribution packages to PyPI (
publish.yml
). A published release triggers this action:- build distribution package on Python
3.10
- upload the new package to PyPI
- build distribution package on Python
Follow these steps to create a new release:
- Commit all changes
- Run
pytest
andpylint
and correct all warnings and errors - Generate documentation locally and check it
- Change the version number in
pyproject.toml
- Update
CHANGELOG.md
with the new release information - Update the version number in
docs/source/conf.py
- Commit all changes and test again
- Create a new release on GitHub with the same version number and the new package will be published on PyPI automatically