test-python-repo
User guide for the demo package repository at
https://github.com/neerajmythink/test-python-repo.
This repository is used to test:
- Python package versioning from Git tags
- wheel and source distribution builds
- publishing to PyPI from GitHub Actions
- pulling the package from PyPI or Cloudsmith
Overview
The repository name is test-python-repo, while the published Python package name is
dummy-versioning-demo.
The import name is dummy_versioning_demo.
Current package features:
hello()returns a simple demo string__version__is generated automatically from Git metadata- tests verify both the import and installed package version metadata
Repository layout
pyproject.toml- package metadata and build configurationsrc/dummy_versioning_demo/- package source codetests/- package tests.github/workflows/ci.yml- test matrix and build validation.github/workflows/publish.yml- publish to PyPI on GitHub releasepackage_build.sh- create annotated release tag and build package artifactspackage_push.sh- local upload helper usingtwinepackage_pull.sh- install helper for PyPI or Cloudsmith
Requirements
- Python
3.9or newer pip- Git tags available locally when building release versions
For local build and release testing, install:
buildpytesttwine
Install for development
Create and activate a virtual environment, then install the package in editable mode.
Recommended flow:
pip install --upgrade pippip install -e .pip install pytest build twine
Run the package locally
After installation, test the package in Python:
import dummy_versioning_demodummy_versioning_demo.hello()dummy_versioning_demo.__version__
Run tests
Run the test suite with:
pytest -q
The test suite verifies:
- the package imports correctly
hello()returns the expected demo output- installed package metadata matches
dummy_versioning_demo.__version__
Build distributions
Build both a wheel and source distribution with:
python -m build
Or use the helper script to create an annotated release tag and build in one step:
./package_build.sh 0.1.0./package_build.sh 0.1.0 --push
Artifacts are created in dist/:
*.whl*.tar.gz
Versioning
This repository uses setuptools-scm, so version numbers are generated automatically from Git tags.
You should not manually edit src/dummy_versioning_demo/_version.py.
Examples:
- Git tag
v0.1.0-> package version0.1.0 - commits after that tag -> development versions such as
0.1.devN
If your build currently shows 0.1.dev3, it means the build was created from a commit that is not exactly on the v0.1.0 tag.
To build version 0.1.0 exactly:
- Commit your release-ready changes.
- Create an annotated tag such as
v0.1.0on that commit. - Push the tag to GitHub.
- Rebuild the package.
You can automate steps 2 through 4 with:
./package_build.sh 0.1.0 --push
Useful checks:
git taggit describe --tags --exact-matchgit ls-remote --tags origin
GitHub Actions
CI workflow
.github/workflows/ci.yml runs on pushes to main and on pull requests.
It performs the following steps:
- tests on Python
3.9,3.10,3.11, and3.12 - installs the package in editable mode
- runs
pytest - builds distribution artifacts
Publish workflow
.github/workflows/publish.yml publishes to PyPI when a GitHub release is published.
It:
- checks out the repo with full tag history
- builds the package
- publishes using
pypa/gh-action-pypi-publish
Publish to PyPI
Recommended: GitHub trusted publishing
This is the cleanest setup for this repo.
To enable it:
- In PyPI, configure a Trusted Publisher for
neerajmythink/test-python-repo. - In GitHub, keep or create the
pypienvironment. - Create a GitHub release from a version tag such as
v0.1.0.
When the release is published, GitHub Actions builds and uploads the package to PyPI.
Local publish with twine
The repo also includes package_push.sh for local uploads.
Before using it, export your PyPI token in the shell:
export TWINE_USERNAME=__token__export TWINE_PASSWORD=<your-pypi-token>
Then run the helper script or upload directly with twine.
Install from package indexes
The helper script package_pull.sh supports installing:
- from PyPI
- from Cloudsmith
It also supports these install modes:
- fixed version, currently
==0.1.0 - latest version
- version range
>=0.1.0,<0.2.0
For PyPI, equivalent examples are:
pip install 'dummy-versioning-demo==0.1.0'pip install 'dummy-versioning-demo'pip install 'dummy-versioning-demo>=0.1.0,<0.2.0'
Notes
- Keep
fetch-depth: 0in CI and publish workflows so tag-based versioning works correctly. - If there is no exact release tag on the current commit,
setuptools-scmwill generate a development version. - The package name (
dummy-versioning-demo) is different from the repository name (test-python-repo), which is normal but worth remembering during install and publish steps.
Metadata
Release files for dummy-versioning-demo 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dummy_versioning_demo-0.4.0.tar.gz | 11.8 kB | Without provenance | Details for dummy_versioning_demo-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dummy_versioning_demo-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for dummy_versioning_demo-0.4.0-py3-none-any.whl |
Total release size: 17.5 kB
Release files / dummy_versioning_demo-0.4.0.tar.gz
| Download URL | dummy_versioning_demo-0.4.0.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eb23e083652fcb19e733456a8b115bfd915ce615920b765a120e53a3f9523663
|
|
BLAKE2b-256 checksum How to use checksums |
8933c827e638c81c35ce6af7e79d2f17a6f7969913fc9a6069e208b33ff6c24c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / dummy_versioning_demo-0.4.0-py3-none-any.whl
| Download URL | dummy_versioning_demo-0.4.0-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
88b246a3672722dff4a504cc829b359e3da6d6dd7dd5e080c5c302d0a391ba66
|
|
BLAKE2b-256 checksum How to use checksums |
c8200dfa4217437a8bf99266f53317f1b74585082667ae77bea562b69e2c75f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Security for dummy-versioning-demo 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.