Skip to content

joamatab/cookiecutter-pypackage-minimal

 
 

Repository files navigation

Python package template 0.0.5

Code style: black

Usage

Start a new python project running

pip install cookiecutter
cookiecutter gh:joamatab/cookiecutter-pypackage-minimal

It will ask you some questions to fill the template

If you want to run a branch or a different version

cookiecutter gh:joamatab/cookiecutter-pypackage-minimal --checkout branch_name

🚀 Features

In this cookiecutter 🍪 template we combine state-of-the-art libraries and best development practices for Python.

Makefile

The Makefile provides you with an easy way to:

  • install: the package
  • test: run tests
  • cov: get test coverage
  • mypy: check types
  • ruff: fixer

Precommit hooks

Precommit hooks enforces that the code that you commit follows some standards:

You can comment them in .pre-commit-config.yaml

  • Standard
    • check-yaml
    • end-of-file-fixer
    • trailing-whitespace
  • Black: format your code
  • nbstripout: strips jupyter notebooks output, so they can be version controlled
  • reorder-python-imports: sorts imports
  • ruff

CI/CD

See .github/workflows

  • test_code.yml: runs tests for code and docs. Uses pip install
  • test_code_conda.yml: runs tests. Uses conda. Choose this one if some dependencies are only on conda. Otherwise delete this one.
  • release.yml: publishes to PyPI any new releases, need to add Pypi token to your Github account
  • pages.yml: builds docs.

README

  • README uses markdown format

LICENSE

  • MIT license by default This template provides you the classic MIT licence: it lets people do almost anything they want with your project, including to make and distribute closed source versions. If you choose another license, you also need to update the {{ package_name }}/setup.py file: adjust the classifiers and license fields accordingly.

Testing

  • Uses pytest as the default test runner This can be changed easily, though pytest is a easier, more powerful test library and runner than the standard library's unittest. The tests directory should not be a Python package unless you want to define some fixtures. But the best practices are to use PyTest fixtures which provides a better solution. Therefore, the tests directory has no __init__.py file.

Docs

you can mix and match markdown and RST syntax in the index for your docs.

I prefer markdown but I also embed RST commands as


.. autofunction:: module.function_name

To build the docs you need to have the package itself installed, you can do this by:

cd path_to_your_repo
make install
cd docs

Alternatively, you can install the dependencies of the package as:

cd path_to_your_repo
make python-deps
cd docs
make html

References

About

A minimal template for python packages

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 83.2%
  • Makefile 11.6%
  • Jinja 5.2%