Python Package Documentation#
Example Python package#
All design principles are explained in the developing.md file. The Python package template was created by Jakob Nybo Nissen and Henry Webel.
How to use#
Can be used as GitHub template repository, see GitHub documentation.
You will need to find and replace occurences of
python_package->your_package_namealso the folder
src/python_package
RasmussenLab->GitHub_user_name(ororganization) with the name of your package and GitHub user name (or organization).look for
First Lastto see where to replace with your namechoose a license, see GitHub documentation and Creative Commons. Replace
LICENSEfile with the license you choose.Update the
CITATION.cfffile with your information.once you change the code under
src, please make sure to updatedocs/tutorial/tutorial.ipynb(add your usage example)tests/test_mockup.py(delete file and add your own tests following the naming conventionstest_<filename>.py)
Development environment#
Install package so that new code is picked up in a restared python interpreter:
pip install -e ".[dev]"
Then you want to run locally the commands which are check in the CI/CD pipeline (using GitHub Actions). You can type
# run unittests
pytest tests
# format code and sort imports
black .
isort .
# lint code and check for obvious errors
ruff check src
Basic usage#
works using this template
from python_package import hello_world
print (python_package.__version__)
print(hello_world(4))
Readthedocs#
The documentation can be build using readthedocs automatically. See project on Readthedocs for the project based on this template. A new project needs to be registered on ReadTheDocs.
make sure to enable build from PRs in the settings (advanded settings)
checkout configuration file:
.readthedocs.yaml