Catalogue / python-package-release
python-package-release
Older skill: source not recordedSignedPrepares Python package metadata, entry points, versioning, wheels, source archives, and an approved index release using uv and a selected build backend. Use for packaging, editable installs, or PyPI/private-index release preparation. Do not use to publish without confirmation or to replace general…--- name: python-package-release description: >- Prepares Python package metadata, entry points, versioning, wheels, source archives, and an approved index release using uv and a selected build backend. Use for packaging, editable installs, or PyPI/private-index release preparation. Do not use to publish without confirmation or to replace general application development. ---
Python distribution build and release checks
Treat the artifact, its contents, and its target registry as separate decisions. Prepare a reproducible package and a release plan before any upload.
Define the package contract
Settle these before writing metadata:
- Distribution name vs import package — the distribution may use hyphens while the import directory uses underscores
- Supported Python versions, license ownership, runtime dependencies
- Public API surface, command entry points, and the release destination
- Layout — prefer
src/so tests cannot accidentally import the working directory - Shipping material — a substantive README, the real license text, public API docs, type hints, and a
py.typedmarker when inline typing ships
Get explicit approval before creating or modifying files, changing versions or tags, installing tools or editable packages, building archives, creating environments, uploading, or changing registry settings. Show the exact target, commands, artifacts, and expected effects, and check installed help and project configuration first. Note that builds execute backend code and fetch build dependencies, so approval must cover those effects. Never build untrusted third-party source merely to inspect it.
The following is a complete small scaffold for an owner-approved project. Every shown path is a project output to create after approval, not a companion file bundled with this skill. Replace identities, URLs, license text, and metadata with actual owner-approved values.
measure-note-tools/
pyproject.toml
README.md
LICENSE
src/measure_note_tools/
__init__.py
cli.py
gui.py
plugins.py
py.typed
tests/[build-system]
requires = ["setuptools>=77", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "measure-note-tools"
version = "0.3.2"
description = "Formats concise measurement notes"
readme = "README.md"
requires-python = ">=3.11"
license = "MIT"
license-files = ["LICENSE"]
authors = [{name = "Package Maintainer", email = "maintainer@example.invalid"}]
keywords = ["measurement", "notes"]
dependencies = []
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Topic :: Software Development :: Libraries",
]
[project.optional-dependencies]
dev = ["pytest", "ruff"]
[project.urls]
Homepage = "https://example.invalid/measure-notes"
Documentation = "https://example.invalid/measure-notes/docs"
Repository = "https://example.invalid/measure-notes/repository"
Issues = "https://example.invalid/measure-notes/issues"
[project.scripts]
measure-note = "measure_note_tools.cli:main"
[project.gui-scripts]
measure-note-window = "measure_note_tools.gui:main"
[project.entry-points."measure_note_tools.renderers"]
plain = "measure_note_tools.plugins:render"
[tool.setuptools.packages.find]
where = ["src"]
[tool.setuptools.package-data]
measure_note_tools = ["py.typed"]Use the following contents for __init__.py; a separate version module is optional when the backend derives package metadata reliably. Do not duplicate manually maintained versions in multiple files.
from decimal import Decimal, InvalidOperation
def format_note(value: str, unit: str) -> str:
try:
number = Decimal(value)
except InvalidOperation as exc:
raise ValueError("measurement must be numeric") from exc
if not number.is_finite() or not unit.strip():
raise ValueError("finite measurement and nonempty unit required")
return f"{number.normalize():f} {unit.strip()}"cli.py supplies the console entry point; invoking the parser without arguments prints usage through argparse's normal error behavior.
import argparse
from . import format_note
def main() -> int:
parser = argparse.ArgumentParser(description="Format one measurement")
parser.add_argument("value")
parser.add_argument("unit")
args = parser.parse_args()
try:
print(format_note(args.value, args.unit))
except ValueError as exc:
parser.error(str(exc))
return 0
if __name__ == "__main__":
raise SystemExit(main())plugins.py defines an importable plugin callable, rather than a console command:
from . import format_note
def render(value: str, unit: str) -> str:
return format_note(value, unit)gui.py is an optional desktop entry point. Keep it only when desktop distribution is intended and Tk is available; a GUI script is not automatically a packaged desktop application.
from . import format_note
def main() -> None:
import tkinter as tk
root = tk.Tk()
root.title("Measurement note")
value, unit = tk.StringVar(value="2.5"), tk.StringVar(value="m")
result = tk.StringVar()
tk.Entry(root, textvariable=value).pack()
tk.Entry(root, textvariable=unit).pack()
def update() -> None:
try:
result.set(format_note(value.get(), unit.get()))
except ValueError as exc:
result.set(str(exc))
tk.Button(root, text="Format", command=update).pack()
tk.Label(root, textvariable=result).pack()
root.mainloop()Choose classifiers from the registry's current list, based on actual support:
- Maturity: Alpha / Beta / Production-Stable
- Audience: Developers, Science/Research
- Python versions actually tested, applicable frameworks
- Topic: software libraries, scientific tools
Do not claim a framework or Python version merely for search visibility. License metadata syntax depends on backend support; this scaffold uses an SPDX expression with a backend that supports it. Include the full approved LICENSE contents, not an invented legal statement. README must explain installation, API, CLI, and supported platforms.
Choose one backend and one version source
The frontend uv build invokes the backend named in [build-system]; uv is not itself a promise that any particular backend is selected.
| Backend | Build requirement and backend identifier | Selection consideration | | --- | --- | --- | | setuptools | setuptools plus wheel; setuptools.build_meta | Existing setuptools projects and explicit package discovery | | uv build backend | uv_build; uv_build | Simple packages matching its supported layout/configuration | | Hatchling | hatchling; hatchling.build | Hatch-oriented build hooks and layouts | | Flit | flit_core; flit_core.buildapi | Small packages fitting Flit's metadata model | | Poetry backend | poetry-core; poetry.core.masonry.api | Projects already configured for Poetry packaging |
When changing backend, verify installed/current backend documentation, supported metadata, included files, and compatible requirement versions. Lock or constrain approved build dependencies for the release environment. Do not reuse another backend's discovery or version settings unchanged.
For manual versioning, keep the single [project].version value and follow the declared compatibility policy:
- Major — breaking changes
- Minor — compatible additions
- Patch — compatible fixes
Python package versions must also be valid PEP 440; prereleases can describe test releases without falsely claiming stability.
For tag-derived versions, omit the static version, declare dynamic = ["version"], and configure a version provider actually supported by the chosen backend, such as an approved setuptools-scm integration for setuptools. Add its build dependency, verify tag parsing, dirty-tree behavior, source-archive fallback, and metadata agreement. A generic [tool.uv] version-provider = "git" is not a portable implementation of dynamic versioning. Test the actual backend configuration before release and confirm before creating a tag.
Validate artifacts locally
After explicit approval, uv build builds both wheel and source distribution into dist/; uv build --wheel or uv build --sdist selects one format. The installed CLI may provide --out-dir for an isolated release directory. Prefer an isolated directory or an explicit reviewed artifact list to uploading stale output. Do not clear or delete existing output without approval.
For an approved editable development install into a selected environment, use the installed frontend's supported equivalent of uv pip install --python <environment-python> -e '.[dev]'. Editable imports test development behavior, not whether the wheel contains everything.
Inspect wheel and source archive contents without extracting untrusted paths:
- Package modules, typing marker, metadata, README and license are present
- Expected entry points exist
- No tokens, local configuration, caches, or private data included
Then: rebuild a wheel from the source archive to catch missing build inputs; install it into an approved isolated environment; smoke-test imports, the console command, and plugin discovery; compare its version to the release plan; test supported interpreters, not only the checkout import path. Record exactly what was checked and any unavailable tools.
Separate rehearsal from release
Choose PyPI, TestPyPI, or a private index before requesting upload approval. Confirm account/project authorization, version, exact files and hashes, and the credentials source. Use an owner-provisioned token through the installed publisher's environment support or a verified trusted-publishing integration; do not paste tokens into command arguments, logs, files, or chat. Do not assume uv reads .pypirc; verify the installed authentication mechanism.
With explicit upload confirmation, the ordinary public release command is uv publish <approved-wheel> <approved-source-archive>. With verified CLI environment-token support, an owner-provisioned UV_PUBLISH_TOKEN can authenticate without a literal secret in argv. Public-index defaults must be confirmed rather than inferred from a prior command.
For a separately approved TestPyPI rehearsal:
uv publish --publish-url https://test.pypi.org/legacy/ <approved-files> # then, in a separate environment: pip install --index-url https://test.pypi.org/simple/ measure-note-tools==0.3.2
Dependencies may not exist there: use an explicitly approved dependency strategy rather than silently adding an untrusted fallback index. A TestPyPI upload does not authorize a production upload.
For a private registry, use its documented upload endpoint with --publish-url or an approved named index configuration. The /simple/ URL normally serves package discovery; it is not automatically the upload endpoint. Verify both URLs and authentication requirements with the registry owner.
Before production upload, review the rehearsed artifacts and confirm exact hashes and destination again. Distribution versions generally cannot be overwritten; decide the new version before attempting a repair. Report uploaded filenames and observed responses, then verify installation from the intended index. A dry run or build success is not proof of publication.
Never
Never
- Write files, install/editably install, build, tag, create environments, upload, or change registry settings without explicit human confirmation.
- Embed or echo credentials, assume
.pypircsupport, or treat a package download URL as an upload endpoint. - Upload every historical file in dist/ without checking the exact release artifact list.
- Claim source and wheel parity, supported interpreters, GUI availability, or publication without observed evidence.
Preview shortened. The full SKILL.md is in the pack.
| File | Size | SHA-256 |
|---|---|---|
| SKILL.md | 12.1 kB | 289f66493152 |
| examples.json | 2.0 kB | b27c00aee0f2 |
Published verbatim from the pinned commit. Nothing is rewritten.
| Version | Pinned commit | Signed | |
|---|---|---|---|
| 1.0.1 Current | Not recorded | 6 Oct 2026 | |
| 1.0.0 | Not recorded | 3 Oct 2026 |
Locking a skill to one version needs Pro.