Skip to main content

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 configuration
  • src/dummy_versioning_demo/ - package source code
  • tests/ - package tests
  • .github/workflows/ci.yml - test matrix and build validation
  • .github/workflows/publish.yml - publish to PyPI on GitHub release
  • build_package.sh - create annotated release tag and build package artifacts
  • push_package.sh - local upload helper using twine
  • pull_package.sh - install helper for PyPI or Cloudsmith

Requirements

  • Python 3.9 or newer
  • pip
  • Git tags available locally when building release versions

For local build and release testing, install:

  • build
  • pytest
  • twine

Install for development

Create and activate a virtual environment, then install the package in editable mode.

Recommended flow:

  • pip install --upgrade pip
  • pip install -e .
  • pip install pytest build twine

Run the package locally

After installation, test the package in Python:

  • import dummy_versioning_demo
  • dummy_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:

  • ./build_package.sh 0.1.0
  • ./build_package.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 version 0.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:

  1. Commit your release-ready changes.
  2. Create an annotated tag such as v0.1.0 on that commit.
  3. Push the tag to GitHub.
  4. Rebuild the package.

You can automate steps 2 through 4 with:

  • ./build_package.sh 0.1.0 --push

Useful checks:

  • git tag
  • git describe --tags --exact-match
  • git 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, and 3.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:

  1. In PyPI, configure a Trusted Publisher for neerajmythink/test-python-repo.
  2. In GitHub, keep or create the pypi environment.
  3. 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 push_package.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 pull_package.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: 0 in CI and publish workflows so tag-based versioning works correctly.
  • If there is no exact release tag on the current commit, setuptools-scm will 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

dummy_versioning_demo-0.3.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dummy_versioning_demo-0.3.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file dummy_versioning_demo-0.3.0.tar.gz.

File metadata

  • Download URL: dummy_versioning_demo-0.3.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for dummy_versioning_demo-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7777baea9015c82aa17f02903dd50d5d915d47275316c01c8d9ad3993600bf71
MD5 e2a9314f07e88e4e631a4eb7ed422f28
BLAKE2b-256 a61be5d2c97ebce836febf6c6e8d5e9765457176e41591b0241f9218eae7ef4f

See more details on using hashes here.

File details

Details for the file dummy_versioning_demo-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dummy_versioning_demo-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93746ff2fde2f71519d477ba7bc3a65f4b5f7cb824672b2bdaa38936306d3d74
MD5 79c8931533ba3387453dfe82644c8689
BLAKE2b-256 9937734957b532b03efe4e43b2c9dd54f52f4eca1789469f0d8a69121256fd23

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page