Skip to main content

Python Package Template

The template repository for creating python packages, shared across auth-broker.

Python UV Hatchling Ruff Pre-commit Pytest Coverage GitHub Actions PyPI Docker Compose Makefile

🦜🕸️

CI


Template Checklist

  • [ ] Rename module src/ab_core/template -> src/ab_core/your_package_name
  • [ ] Rename tests module src/ab_core/template -> src/ab_core/your_package_name
  • [ ] Update pyproject.toml: [project] section based on your package name / versioning etc.
  • [ ] Update README.md references of python-package-template -> your-package-name
  • [ ] Update Dockerfile entrypoint
  • [ ] Update docker compose port entrypoint
  • [ ] Update vscode launch.json port and entrypoint
  • [ ] Remove this section

Table of Contents


Introduction

This template repository aims to create a reusable package template which streamlines the creation and publishing of isolated python packages in auth-broker. This is aligned with the engineering vision @ auth-broker for better modularisation and reusability of code.


Quick Start

Since this is just a package, and not a service, there is no real "run" action. But you can run the tests immediately.

Here are a list of available commands via make.

Bare Metal (i.e. your machine)

  1. make install - install the required dependencies.
  2. make test - runs the tests.

Docker

  1. make build-docker - build the docker image.
  2. make run-docker - run the docker compose services.
  3. make test-docker - run the tests in docker.
  4. make clean-docker - remove all docker containers etc.

Installation

For Dev work on the repo

Install uv, (if you haven't already) https://docs.astral.sh/uv/getting-started/installation/#installation-methods

brew install uv

Initialise pre-commit (validates ruff on commit.)

uv run pre-commit install

Install dependencies (including dev dependencies)

uv sync

If you are adding a new dev dependency, please run:

uv add --dev {your-new-package}

Namespaces

Packages all share the same namespace ab_core. To import this package into your project:

from ab_core.template import placeholder_func

We encourage you to make your package available to all of ab via this ab_core namespace. The goal is to streamline development, POCs and overall collaboration.


Usage

Adding the dependency to your project

The library is available on PyPI. You can install it using the following command:

Using pip:

pip install python-package-template

Using UV

Note: there is currently no nice way like poetry, hence we still needd to provide the full url. https://github.com/astral-sh/uv/issues/10140

Add the dependency

uv add python-package-template

Using poetry:

Then run the following command to install the package:

poetry add python-package-template

How tos

Example Usage

# Please update this based on your package!

from ab_core.template import placeholder_func


if __name__ == "__main__":
    print("This is a placeholder: ", placeholdder_func())

Formatting and linting

We use Ruff as the formatter and linter. The pre-commit has hooks which runs checking and applies linting automatically. The CI validates the linting, ensuring main is always looking clean.

You can manually use these commands too:

  1. make lint - check for linting issues.
  2. make format - fix linting issues.

CICD

Publishing to PyPI

We publish to PyPI using Github releases. Steps are as follows:

  1. Manually update the version in pyproject.toml file using a PR and merge to main. Use uv version --bump {patch/minor/major} to update the version.
  2. Create a new release in Github with the tag name as the version number. This will trigger the publish workflow. In the Release window, type in the version number and it will prompt to create a new tag.
  3. Verify the release in PyPI

Metadata

Release files for ab-template-service 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ab-template-service 0.3.0
File Size Uploaded Provenance Actions
ab_template_service-0.3.0.tar.gz 7.1 kB Without provenance Details for ab_template_service-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ab-template-service 0.3.0
File Interpreter ABI Platform Actions
ab_template_service-0.3.0-py3-none-any.whl Python 3 none any Details for ab_template_service-0.3.0-py3-none-any.whl

Total release size: 13.5 kB

Release files / ab_template_service-0.3.0.tar.gz

Download URL ab_template_service-0.3.0.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
07a4127b959c6ef8a8cca2f755848d36de99a9f2c8fc1b2717c76affdf9a2f17
BLAKE2b-256 checksum
How to use checksums
f752afd06309597aacd2a06a96e43b514042f423a87436cbbe64949d0878d610
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ab_template_service-0.3.0-py3-none-any.whl

Download URL ab_template_service-0.3.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bcb9482365de4bb7bac7b1bd3cfe40265fcca37d739fe06b51352894695aea16
BLAKE2b-256 checksum
How to use checksums
05a930c5e5e39dc871a29b7bb70ed1626b9340f3c615d56ba4fb92527c4e780c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for ab-template-service 0.3.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.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page