No description
Find a file
Alexandre MOREAU c9e391333e Uppercase message
2026-05-29 11:01:17 +02:00
doc/assets Initial package commit 2026-05-29 08:39:26 +02:00
src/mypackage Uppercase message 2026-05-29 11:01:17 +02:00
tests Uppercase message 2026-05-29 11:01:17 +02:00
.gitignore Package init and pytest 2026-05-29 10:37:06 +02:00
Makefile Makefile added 2026-05-29 10:56:02 +02:00
poetry.lock Package init and pytest 2026-05-29 10:37:06 +02:00
pyproject.toml Uppercase message 2026-05-29 11:01:17 +02:00
README.md Documentation update 2026-05-29 10:06:43 +02:00

My Package

A demonstration of how build and deploy a Python package using poetry.

Package initilization

poetry new mypackage
  • Code can now be updated
  • Package vesion will be taken from the pyproject.toml file version field.

Package build

poetry build

This will generate a dist folder with a whl file and a tar.gz file. The first one is the package, the second is an archive of the source files.

.
├── dist
│   ├── mypackage-0.1.0-py3-none-any.whl
│   └── mypackage-0.1.0.tar.gz
├── pyproject.toml
├── README.md
├── src
│   └── mypackage
│       ├── __init__.py
│       └── libmountyfox.py
└── tests
    └── __init__.py

Poetry configuration to publish on local PyPi equivalent.

  1. Configure the repository that Poetry can contact
poetry config repositories.self-forgejo https://forgejo.mountyfox.ch/api/packages/<ORG_OR_USER>/pypi
  1. Configure authentication for that repository
poetry config http-basic.self-forgejo <USER> <TOKEN>
  1. Ignore SSL certificate verification if need (if self-signed certificate on server)
poetry config certificates.self-forgejo.cert false

Note: The configuration files for poetry can be found in ~/.config/pypoetry directory.

Package publishing

poetry publish -r self-forgejo
Publishing mypackage (0.1.0) to self-forgejo
 - Uploading mypackage-0.1.0.tar.gz 0%/usr/local/lib/python3.11/dist-packages/urllib3/connectionpool.py:1110: InsecureRequestWarning: Unverified HTTPS request is being made to host 'forgejo.mountyfox.ch'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
  warnings.warn(
 - Uploading mypackage-0.1.0.tar.gz 100%
 - Uploading mypackage-0.1.0-py3-none-any.whl 0%/usr/local/lib/python3.11/dist-packages/urllib3/connectionpool.py:1110: InsecureRequestWarning: Unverified HTTPS request is being made to host 'forgejo.mountyfox.ch'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
  warnings.warn(
 - Uploading mypackage-0.1.0-py3-none-any.whl 100%

Then the package is uploaded to the repository server.

mypackage

Note: independantly from the package in-build version, it is a good practice to tag the source code with the version. It helps keeping relation between deployment package distributed to users and the code repository

git tag 0.1.0
git push origin main --tags