Skip to main content

sahra-shared

PyPI Python License: MIT

A reusable Python library — the shared kernel for Sahra Trans services.

sahra-shared is a library, not a service. It has no HTTP server, no database, no port, no container and no entrypoint. Nothing here starts; you import it. It is published to PyPI and consumed by the Sahra Trans services as an ordinary dependency.

The import namespace is sahra_shared.

Install

uv add sahra-shared

Use

from sahra_shared.auth import Capability, CapabilityGuards
from sahra_shared.events import NATSPublisher, SahraEvent
from sahra_shared.http import ProblemDetail, make_health_router
from sahra_shared.privacy import CountryPrivacyPolicy, PIIEmail
from sahra_shared.telemetry import AppLogger, setup_otel
from sahra_shared.tenancy import TenantScope, tenant_transaction

What it provides

Sub-package Surface
sahra_shared.auth TokenClaims, RS256 JWT verification against JWKS, the closed Capability vocabulary and deny-by-default CapabilityGuards
sahra_shared.events SahraEvent (CloudEvents envelope), NATSPublisher / consumer helpers
sahra_shared.http ProblemDetail (RFC 7807) and make_health_router — a router factory a service mounts; this library serves nothing itself
sahra_shared.privacy PII types (PIIEmail, PIIPhone, …) and per-country privacy policies
sahra_shared.telemetry OpenTelemetry setup, structured logging, call_service (propagates traceparent)
sahra_shared.tenancy TenantScope, transaction-bound tenant context, row-level-security helpers

Sub-packages are independent: they do not import one another (only telemetry is depended upon in common). That boundary is enforced by tests/test_import_boundaries.py.

Requirements

Python >= 3.13.

Development

This repository is uv-only. Do not use pip, venv, Poetry or Twine.

uv sync --all-groups        # install dev + test dependency groups
uv run pytest               # tests
uv run ruff check .         # lint
uv run ruff format --check .# format
uv run ty check             # type-check
uv build                    # build wheel + sdist

uv.lock is committed deliberately: the resolved dependency set is part of what a release tag means.

Documentation

Design notes, the tenancy/RLS reference and the logging integration guide live in the project repository alongside the source, and are not shipped in the distribution.

Releasing

Releases are built and published to PyPI by GitHub Actions using Trusted Publishing (OIDC). There is no PyPI API token and no stored publishing credential. A vX.Y.Z tag builds, gates and publishes; a vX.Y.Z-rc1 tag runs the identical gate and stops before publishing.

License

MIT — see LICENSE.

Metadata

Release files for sahra-shared 0.5.1

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

Source distribution (sdist)

Source distribution for sahra-shared 0.5.1
File Size Uploaded Provenance Actions
sahra_shared-0.5.1.tar.gz 142.2 kB Without provenance Details for sahra_shared-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sahra-shared 0.5.1
File Interpreter ABI Platform Actions
sahra_shared-0.5.1-py3-none-any.whl Python 3 none any Details for sahra_shared-0.5.1-py3-none-any.whl

Total release size: 232.6 kB

Release files / sahra_shared-0.5.1.tar.gz

Download URL sahra_shared-0.5.1.tar.gz
Size 142.2 kB
Tags Source
SHA-256 checksum
How to use checksums
33bea2ff6c299af7b43346eab776e68635c59b4f3cb553a4d72f473bbe7ee07f
BLAKE2b-256 checksum
How to use checksums
fb82f8c3baaf4d05796cf040e06ddc671d0c32138e0fbbc017d23dbfcee51b01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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 / sahra_shared-0.5.1-py3-none-any.whl

Download URL sahra_shared-0.5.1-py3-none-any.whl
Size 90.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
492ed41a0cfd4a4bcdf520d53af199718768f069fd228fe2f8756fb0c730b9c3
BLAKE2b-256 checksum
How to use checksums
c3dffd2a14881269e2d664b324fed1a8af4c03ab6b31467d08241b3c72f84515
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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 sahra-shared 0.5.1

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.

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