Dummy package for testing Python versioning and PyPI publishing
Project description
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.
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 dummy_versioning_demo-0.4.0.tar.gz.
File metadata
- Download URL: dummy_versioning_demo-0.4.0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb23e083652fcb19e733456a8b115bfd915ce615920b765a120e53a3f9523663
|
|
| MD5 |
0ecb360a262b265a80eb09e885edfe94
|
|
| BLAKE2b-256 |
8933c827e638c81c35ce6af7e79d2f17a6f7969913fc9a6069e208b33ff6c24c
|
File details
Details for the file dummy_versioning_demo-0.4.0-py3-none-any.whl.
File metadata
- Download URL: dummy_versioning_demo-0.4.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88b246a3672722dff4a504cc829b359e3da6d6dd7dd5e080c5c302d0a391ba66
|
|
| MD5 |
b5c217031ac96d26d2fba90f45b0e128
|
|
| BLAKE2b-256 |
c8200dfa4217437a8bf99266f53317f1b74585082667ae77bea562b69e2c75f4
|