/pyproject-template

Python package template for cool people

Primary LanguageShellOtherNOASSERTION

pyproject template

GitHub tag (latest by date) GitHub Workflow Status pre-commit Code style: black Codecov GitHub issues GitHub pull requests License Read the Docs

Template for modern Python package GitHub repositories.

Quick configuration

  1. Clone the repository locally
  2. Run the interactive configuration script:
    $ cd pyproject-template
    $ ./template-config.sh
  3. Rename the repository folder to your new repository name
  4. Fill in the missing information in setup.cfg
  5. Remove any template instruction from this README.md (but keep the footer at the end!)
  6. Choose a license and save its statement in LICENSE
  7. Remove the template-config.sh file
  8. Create a new (empty) GitHub repository matching your user/repo
  9. Create a new commit with the unstaged changes and git-push to the remote
  10. Activate (you can log in with your GitHub credentials):
  11. [Optional] Get a PyPI token and add it as a repository secret on GitHub (name it PYPI_PASSWORD) to enable publishing the package.

Quick start

  • Install:
    $ pip install .
    $ pip install .[test] # get ready to run tests
    $ pip install .[docs] # get ready to build documentation
    $ pip install .[all]  # get all from above
  • Build documentation:
    $ cd docs
    $ make        # build docs for the current version
  • Run tests with pytest
  • Run pre-commit hooks with pre-commit run --all-files
  • Release a new version:
    $ git tag v0.1.0
    $ git checkout -b releases/v0.1 # to apply patches, if needed, later
    $ git push v0.1.0

Optional customization

  • Customize the python versions / operative systems to test the package against in .github/workflows/main.yml
  • Edit the pre-commit hook configuration in .pre-commit-config.yaml. A long list of hooks can be found here
  • Adapt the Sphinx configuration in docs/source/conf.py
  • Building wheels with GitHub actions currently assumes pure Python wheels. Have a look at this Scikit-HEP documentation to learn how to configure building of binary wheels.

This Python package layout is based on pyproject-template.