python-packaging-uv
Scannednpx machina-cli add skill narumiruna/agent-skills/python-packaging-uv --openclawFiles (1)
SKILL.md
1.1 KB
Python Packaging with uv
Overview
Use uv build and publish commands to produce wheels/sdists and ship to PyPI. Core principle: build, verify, then publish.
Quick Reference
| Task | Command |
|---|---|
| Build wheel+sdist | uv build |
| Build wheel only | uv build --no-sources |
| Publish to PyPI | uv publish --token $PYPI_TOKEN |
| Publish to Test PyPI | uv publish --publish-url https://test.pypi.org/legacy/ --token $TEST_PYPI_TOKEN |
Workflow
- Build artifacts in
dist/. - Test install from wheel.
- Publish to Test PyPI, validate, then publish to PyPI.
Example
uv build --no-sources
uv pip install dist/my_package-1.0.0-py3-none-any.whl
uv publish --publish-url https://test.pypi.org/legacy/ --token $TEST_PYPI_TOKEN
Common Mistakes
- Publishing before verifying wheel contents.
- Skipping Test PyPI for first release.
Red Flags
- Packaging guidance that ignores uv build/publish.
References
references/packaging.md- Build and publish details
Source
git clone https://github.com/narumiruna/agent-skills/blob/main/skills/python-packaging-uv/SKILL.mdView on GitHub Overview
This skill guides you through building Python distributions with uv (wheels and sdists), verifying artifacts, and publishing to PyPI or Test PyPI. It emphasizes a build-verify-publish workflow and relies on dist/ for artifacts.
How This Skill Works
Use uv build to produce distribution artifacts (wheels and sdists) into dist/. You can build a wheel-only package with uv build --no-sources. After verifying the artifact contents, publish to PyPI with uv publish --token $PYPI_TOKEN or to Test PyPI with uv publish --publish-url https://test.pypi.org/legacy/ --token $TEST_PYPI_TOKEN.
When to Use It
- Preparing a new Python package for distribution and release
- Building wheels and sdists for upload to PyPI or Test PyPI
- Verifying dist contents and performing a quick install tests
- First release: validate in Test PyPI before PyPI publication
- Automating or scripting the publish step into CI
Quick Start
- Step 1: uv build
- Step 2: uv pip install dist/my_package-1.0.0-py3-none-any.whl
- Step 3: uv publish --token $PYPI_TOKEN (or use the test URL with $TEST_PYPI_TOKEN for Test PyPI)
Best Practices
- Always run uv build to generate dist/ artifacts before publishing
- Inspect dist/ contents and perform a local install from the wheel to verify packaging correctness
- Use uv publish with a PyPI token; test with Test PyPI first to catch issues
- Publish first to Test PyPI, then to PyPI for a first release
- Avoid publishing before you have validated the wheel contents and dependencies
Example Use Cases
- Build and publish to Test PyPI, verify by installing the wheel, then publish to PyPI
- Build only the wheel with uv build --no-sources, install from dist/, and publish to PyPI
- Publish to Test PyPI using: uv publish --publish-url https://test.pypi.org/legacy/ --token $TEST_PYPI_TOKEN
- Validate a release by installing from dist before clicking publish to PyPI
- Release cadence: uv build -> uv pip install dist/...whl -> uv publish to Test PyPI -> uv publish to PyPI
Frequently Asked Questions
Add this skill to your agents