Skip to main content

poetry_pypi_template

A minimal template for creating a pypi package using poetry and github actions

This template allows the creation of python projects managed by poetry to be submitted to PyPi. All the github actions have been setup too. The github actions run tests on every push and also creates and new pacakage and pushes to the pypi when a merge happens to the release branch.

Just follow the seteps below for an hassle free setup of the project.

Create from the Project Template

  • Click here to create a new repo (you need to be logged in to GitHub for this link to work), and follow the instructions to create a new repo from this template.
  • git clone your new repo

Install Poetry in your Environment

  • activate your environment.
  • install poetry python -m pip install poetry

Update the Project Toml

  • Insert/Update the values in the pyproject.toml under tool.poetry
  • Dont forget to update the desired python version under the tool.poetry.dependencies
  • Dont forget to modify the release branch under tool.semantic_release (assumption is main is the release branch)
  • add project dependancies. eg - if you want numpy as an dependancy simply run poetry add numpy
  • install the dependancies by running poetry install
  • More information on setting up a project with poetry

Write Code for your python package

  • Create a project folder. eg. hapi_pypi here
  • add all the code/implemenations in the folder.

Implement the Tests

  • Check the functionality of the project folder by implementing tests.
  • Implement tests in the tests folder.
  • All the tests should pass when you run the command poetry run pytest tests/
  • Details on how to implement tests with pytest.

Github Actions Configuration

  • all the github actions are defined in the .github/workflows folder
  • setup the test.yml. Update the env variables according to the project setup before. The default coverage limit is set to 90% ie the test will fail below the coverage of 90.
env:
  PYTHON_VERSION: "3.8.5"
  PROJECT_FOLDER: hapy_pypi
  TEST_FOLDER: tests
  COVERAGE_LIMIT: 90
  • setup the similar env variables in release.yml as well.

Setup Secrets

Pypi Creds

These secrets are used to push releases to the pypi repository.

  • Generate a pypi api token
  • Set Repo Secrets
  • Add PYPI_USER as __token__
  • Add PYPI_TOKEN as the token from above step including the pypi- prefix

Github Token

This secret is required to generate the CHANGELOG.MD and update the version by SemRel.

Metadata

Release files for mdatpy 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mdatpy 0.0.4
File Size Uploaded
mdatpy-0.0.4.tar.gz 133.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mdatpy 0.0.4
File Interpreter ABI Platform
mdatpy-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 325.6 kB

Release files / mdatpy-0.0.4.tar.gz

Download URL mdatpy-0.0.4.tar.gz
Size 133.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8d18a2fc74b45db4b9a63b6a6d290c8bb1a02cc218acf29dcbb1f561093519d9
BLAKE2b-256 checksum
How to use checksums
21e272451faa0315d09a5b5027ca47078dbffbeadc798ad9e2931fc12d30921c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.1 CPython/3.10.6 Linux/5.15.0-48-generic

Release files / mdatpy-0.0.4-py3-none-any.whl

Download URL mdatpy-0.0.4-py3-none-any.whl
Size 191.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3abd2f058f3d9b7790db79ca76e28d95231ac2ebde6ca1eac089e17edbea964e
BLAKE2b-256 checksum
How to use checksums
b450bb42029038e51f9703f8c3aff6dabafd98dedb5e9c6e1a1d3d3ff6a360ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.1 CPython/3.10.6 Linux/5.15.0-48-generic

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page