A project template for publication of simple Python packages to PyPI
Project description
Simple Python package
This repository is a minimal template for publishing a small Python package to PyPI using GitHub Actions and trusted publishing.
Quick start
- Fork this repository on GitHub and mark your fork as a template via the repo settings (once)
- Try and/or remove the demo files from your fork:
src/lorenz.py¬ebooks/lorenz_demo.ipynb(once) - Create a pending publisher on PyPI.org (each new project)
- Create a new repository for your project from your template fork on GitHub (each new project)
- Update
pyproject.tomlto reflect your new project's metadata (each new project) - Commit and push your code (each code update)
- Tag and publish a release on GitHub - this will trigger the workflow to publish the current commit to PyPI (each code update)
Project structure
.
├── .devcontainer/ # Dev container config
├── .git/ # Local Git metadata
├── .github/ # GitHub configuration
│ └── workflows/
│ └── publish-to-pypi.yml # Builds package and publishes to PyPI
├── .gitignore # Files and folders Git should ignore
├── LICENSE # Package license
├── pyproject.toml # Package metadata, build system, and dependencies
├── README.md # Project overview and setup instructions
├── requirements.txt # Dev/test dependencies for local usage
├── notebooks/
│ └── lorenz_demo.ipynb # Example notebook demonstrating the package
└── src/
└── lorenz.py # Example module shipped in the package
Usage
1. Fork and mark the template (once)
- Fork this repository.
- In the fork, open Settings → General → Template repository and enable it.
2. Try or remove the demo (once)
This repository ships a tiny demo package (lorenz) used to illustrate packaging and publishing. You can try it locally or remove it before starting your own project.
2.1. Try the demo locally
-
Open your fork in a devcontainer or GitHub Codespace.
-
Install the package in editable mode:
pip install -e .
-
Run the demo notebook notebooks/lorenz_demo.ipynb
2.2. Install the demo from PyPI
Since the demo package has been published to PyPI from this repo, you can install it via pip and use it anywhere:
pip install simple-python-package
2.3. Remove the demo from your fork
If you want a clean template fork to start new projects, simply delete the demo files:
src/lorenz.pynotebooks/lorenz_demo.ipynb
3. Create a pending publisher on PyPI (each new project)
- In PyPI, go to Project → Publishing → Trusted Publishers.
- Add a pending publisher with these values:
- PyPI Project Name: must be unique, site-wide
- Owner: your GitHub user or org
- Repository: your repo name
- Workflow:
publish-to-pypi.yml - Environment:
pypi
Do this first, before naming the GitHub repository to determine if your planned name is available on PyPI. PyPI project names must be unique site-wide. The GitHub repo and PyPI project names don't have to match, but it's nice if they do.
4. Create a new repository from your template (each new project)
- In your template fork, click Use this template on GitHub.
- Create a new repository for your project.
5. Update project metadata (each new project)
Update pyproject.toml with your project metadata:
- Change
name,authors, anddescriptionin[tool.poetry] - Update
classifiersandkeywordsin[tool.poetry] - Update runtime dependencies in
[tool.poetry.dependencies] - Replace or remove
[tool.poetry.urls]
6. Commit and push (each code update)
Use the repo to develop your project as you normally would. Place Python modules to be published as part of your package in the src/ directory. Commit and push your code to GitHub.
7. Tag and publish a release (each code update)
- Create a GitHub release tag that matches your current
versionunder[tool.poetry]inpyproject.toml(e.g.,0.1.0orv0.1.0- see here for information about version numbering). - The Publish to PyPI workflow will build and publish automatically.
If you prefer a manual run, you can trigger the workflow from the Actions tab.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_python_package-0.5.0.tar.gz.
File metadata
- Download URL: simple_python_package-0.5.0.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
965216e77a4ca408156b81dd65baa1456ad8705093b8078271dff355ee5d7e66
|
|
| MD5 |
0222388af929c2c36c42c7e1649c2693
|
|
| BLAKE2b-256 |
3b6bceb76e34455a556bdbcbdc450e603259dd6041a95e940bb7d1e2f6912eb7
|
Provenance
The following attestation bundles were made for simple_python_package-0.5.0.tar.gz:
Publisher:
publish-to-pypi.yml on gperdrizet/simple-python-package
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simple_python_package-0.5.0.tar.gz -
Subject digest:
965216e77a4ca408156b81dd65baa1456ad8705093b8078271dff355ee5d7e66 - Sigstore transparency entry: 888186042
- Sigstore integration time:
-
Permalink:
gperdrizet/simple-python-package@0d60f7e0120a8302e0f2b50d487fdbd2bf90b65b -
Branch / Tag:
refs/tags/0.5.0 - Owner: https://github.com/gperdrizet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@0d60f7e0120a8302e0f2b50d487fdbd2bf90b65b -
Trigger Event:
release
-
Statement type:
File details
Details for the file simple_python_package-0.5.0-py3-none-any.whl.
File metadata
- Download URL: simple_python_package-0.5.0-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6f445535e63ca6a82b30f2510582e3b7ea2cf603ef63768ee3307196b50083b
|
|
| MD5 |
2b4968b2cdf9e5491b79dec8fb83f448
|
|
| BLAKE2b-256 |
3ae5d80ea8bffcd722f8a1a0e3db3f0afd27585ea0394a8733fb6e985dee7028
|
Provenance
The following attestation bundles were made for simple_python_package-0.5.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on gperdrizet/simple-python-package
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simple_python_package-0.5.0-py3-none-any.whl -
Subject digest:
b6f445535e63ca6a82b30f2510582e3b7ea2cf603ef63768ee3307196b50083b - Sigstore transparency entry: 888186084
- Sigstore integration time:
-
Permalink:
gperdrizet/simple-python-package@0d60f7e0120a8302e0f2b50d487fdbd2bf90b65b -
Branch / Tag:
refs/tags/0.5.0 - Owner: https://github.com/gperdrizet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@0d60f7e0120a8302e0f2b50d487fdbd2bf90b65b -
Trigger Event:
release
-
Statement type: