Get the FREE Ultimate OpenClaw Setup Guide →

python-packaging

npx machina-cli add skill athola/claude-night-market/python-packaging --openclaw
Files (1)
SKILL.md
4.1 KB

Table of Contents

Python Packaging

Modern Python packaging with pyproject.toml, uv, and best practices for distribution.

Quick Start

# Create new project with uv
uv init my-package
cd my-package

# Add dependencies
uv add requests click

# Build package
uv build

# Publish to PyPI
uv publish

Verification: Run the command with --help flag to verify availability.

When To Use

  • Creating distributable Python libraries
  • Building CLI tools
  • Publishing to PyPI
  • Setting up development environments
  • Managing project dependencies

When NOT To Use

  • Testing packages - use python-testing instead
  • Optimizing package performance - use python-performance
  • Testing packages - use python-testing instead
  • Optimizing package performance - use python-performance

Core Decisions

1. Layout Choice

# Source layout (recommended)
src/my_package/
    __init__.py
    module.py

# Flat layout (simple)
my_package/
    __init__.py
    module.py

Verification: Run the command with --help flag to verify availability.

Source layout benefits:

  • Clear separation of source and tests
  • Prevents accidental imports of uninstalled code
  • Better for packages with complex structure

2. Project Structure

Minimal Project:

**Verification:** Run `pytest -v` to verify tests pass.
my-project/
├── pyproject.toml
├── README.md
├── src/
│   └── my_package/
│       └── __init__.py
└── tests/
    └── test_init.py

Verification: Run pytest -v to verify tests pass.

Complete Project:

**Verification:** Run the command with `--help` flag to verify availability.
my-project/
├── pyproject.toml
├── README.md
├── LICENSE
├── .gitignore
├── src/
│   └── my_package/
│       ├── __init__.py
│       ├── cli.py
│       ├── core.py
│       └── utils.py
├── tests/
│   ├── conftest.py
│   └── test_core.py
└── docs/
    └── index.md

Verification: Run pytest -v to verify tests pass.

Detailed Topics

See modules for detailed information:

Best Practices

  1. Use source layout for anything beyond simple packages
  2. Pin direct dependencies with minimum versions
  3. Use optional dependency groups for dev/docs/test
  4. Include py.typed for type hint support
  5. Add detailed README with usage examples
  6. Use semantic versioning (MAJOR.MINOR.PATCH)
  7. Test on multiple Python versions before publishing

Exit Criteria

  • Modern pyproject.toml configuration
  • Clear dependency specification
  • Proper version management
  • Tests included and passing
  • Build process reproducible
  • Publishing pipeline automated

Source

git clone https://github.com/athola/claude-night-market/blob/master/plugins/parseltongue/skills/python-packaging/SKILL.mdView on GitHub

Overview

This skill covers creating Python packages and distributing them via PyPI using a pyproject.toml-based workflow with uv. It explains layout choices, project structure, entry points, and CI/CD integration, plus best practices for robust packaging.

How This Skill Works

Packages are built and published via uv commands (init, add, build, publish) guided by a pyproject.toml configuration. The guidance covers source versus flat layouts, module structure, and optional CI/CD strategies to automate releases.

When to Use It

  • Creating distributable Python libraries
  • Building CLI tools
  • Publishing to PyPI
  • Setting up development environments
  • Managing project dependencies

Quick Start

  1. Step 1: uv init my-package; cd my-package
  2. Step 2: uv add requests click; uv build
  3. Step 3: uv publish

Best Practices

  • Use source layout for anything beyond simple packages
  • Pin direct dependencies with minimum versions
  • Use optional dependency groups for dev/docs/test
  • Include py.typed for type hint support
  • Add detailed README with usage examples

Example Use Cases

  • Publish a Python library to PyPI from a pyproject.toml project
  • Build a CLI tool with entry points and uv tooling
  • Distribute a library using a src/ layout to keep source separate from tests
  • Set up CI/CD (GitHub Actions) to automate PyPI publishing
  • Ensure type hints by including py.typed and typing metadata

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers