klaasnicolaas / pypackage-template

πŸ“‘ A copier template for Python projects managed by Poetry

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python Package Template

License GitHub Release

This project has been set up to quickly and easily set up a new Python package project instead of copying and modifying files from previous projects every time. For this we use Copier, which will configure your project based on a questionnaire.

Feature Summary

Create a new project

Assuming you have already correctly installed Copier.

Choose where you would like to create your new project, run the following and answer the questions.

copier gh:klaasnicolaas/pypackage-template path/to/destination

Publishing to PyPI

A GitHub workflow is included that will automatically publish the packaged work to PyPI when a new release is created. To support this, there are some things you need to set up first.

  • Create and verify an account on PyPI.
  • Add a Trusted Publisher to your PyPI account.
  • Create an Environments in the GitHub repository settings. Name it "release", choose selected branches and add a deployment branch rule for main and v*.

Now, when you create a new release from your repository, a workflow will run and deploy the code to PyPI.

Unit test coverage

With every commit push to a pull request, a GitHub workflow will automatically run unit tests and output code coverage into an xml file. To easily see if code coverage is changing as a result of new work, you should install the GitHub app: Codecov.

Future pull requests and commits will now include code coverage information.

Renovate Bot

Renovate checks if updates are available for dependencies and will update them automatically via a pull request. If your repository is set up correctly for auto-merging, the pull request will also be merged automatically.

After this Renovate will create a GitHub issue in your repository which serves as a dashboard, you can see here which updates are pending and trigger Renovate to check again.

Automatic Release Drafts

Automatically generate release notes with the Release Drafter workflow. This uses the labels from issues and pull requests to draft pretty and detailed release notes for your GitHub releases.

Start developing on this template

The project uses Poetry for dependencies management and packaging. Make sure you have it installed in your development machine. To install the development dependencies in a virtual environment, type:

poetry install

This will also generate a poetry.lock file, you should track this file in version control. Check out the Poetry documentation for more information on the available commands.

Pre-commit hooks

This project uses pre-commit to run some checks before committing code. To install the pre-commit hooks, run the following command in the poetry environment:

pre-commit install

Test changes on copier

If you would like to test locally with copier to see what the output is, you can use the command below. So that you can be sure that it takes all changes into account.

copier -r HEAD ./ path/to/destination

Keep template dependencies up to date

The pyproject.toml file of the template has a jinja2 extension and is therefore not seen by Renovate bot to update automatically. That's why I keep track of the dependencies separately in a Gist and a workflow will check every week if anything needs to be adjusted.

License

Distributed under the MIT License. See LICENSE for more information.

About

πŸ“‘ A copier template for Python projects managed by Poetry

License:MIT License


Languages

Language:Jinja 99.6%Language:Python 0.4%