template_python

Starting checklist

  1. Add LICENSE file
  2. Rename pkg_name directory
  3. Rename pkg_name.code-workspace
  4. Update and uncomment badges in this readme, and correct installation instructions
  5. Correct name in environment.yml and adapt
  6. Adapt requirements.txt
  7. Adapt and fill setup.py
  8. Adapt .gitignore as necessary
  9. Once tests are added, uncomment test CI in .github/workflows/CI.yml
  10. For sphinx documentation, update and adapt:
    • docs/source/conf.py
    • docs/source/index.rst
    • docs/run-sphinx-api-doc
    • docs/requirements.txt -- make sure to include all package requirements

Installation

Minimum python version is 3.8. Recommend creating a virtual environment, e.g. assuming your are using Anaconda/Miniconda (if installing conda for the first time, remember to restart the shell before attemting to use conda, and that by default conda writes the setup commands to .bashrc):

conda activate root
conda install nb_conda_kernels
conda env create -f environment.yml
conda activate pkg_name

Otherwise set up a suitable environment using your python distribution of choice using the contents of environment.yml. Remember to activate the correct environment each time, via e.g. conda activate pkg_name.

Install package and dependencies

pip install -r requirements.txt
pip install -e .

Install pre-commit git-hooks:

pre-commit install
pre-commit run --all-files

Testing

Testing is handled by pytest and is set up to run during pull requests. Tests can be manually ran locally via:

pytest tests/

to run all tests, or, e.g.:

pytest tests/test_my_pkg.py

Docs building

  1. CD to docs
  2. Install docs requirements pip install -r requirements.txt
  3. Run run-sphinx-api-doc, and adjust source files as necessary
  4. Run make html
  5. View local docs by opening _build/html/index.html in browser