返回顶部
p

python-packaging

Deep Python packaging workflow—pyproject metadata, dependencies and optional extras, build backends, wheels, versioning, publishing, and CI release hygiene. Use when building libraries or shipping CLI tools to PyPI or private indexes.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
96
下载量
0
收藏
概述
安装方式
版本历史

python-packaging

# Python Packaging (Deep Workflow) Packaging connects source to installable artifacts. Prioritize **reproducible builds**, **accurate dependencies**, and **safe** automated releases. ## When to Offer This Workflow **Trigger conditions:** - New library or CLI; choosing among Poetry, Hatch, setuptools, uv, etc. - Broken installs on some Python versions or platforms - Publishing to PyPI or a private index from CI **Initial offer:** Use **six stages**: (1) project layout, (2) metadata & entry points, (3) dependencies, (4) build backend & wheels, (5) versioning & tags, (6) publish & CI). Confirm supported Python versions and target index. --- ## Stage 1: Project Layout **Goal:** Prefer **`src/`** layout to avoid accidental imports from the repo root; one clear import package name. **Exit condition:** `pip install .` in a clean venv imports the package correctly. --- ## Stage 2: Metadata & Entry Points **Goal:** `pyproject.toml` with PEP 621 metadata; `[project.scripts]` or `[project.gui-scripts]` for CLIs. ### Practices - Link README; specify license SPDX identifier - Use classifiers for PyPI discoverability --- ## Stage 3: Dependencies **Goal:** Separate runtime deps from optional extras (dev, docs, speedups); pin strategy differs for **libraries** vs **applications**. ### Libraries - Avoid overly tight upper bounds unless necessary (avoid dependency hell for consumers) ### Applications - Use lockfiles (pip-tools, uv, poetry lock) for reproducible deploys --- ## Stage 4: Build Backend & Wheels **Goal:** Choose build backend (hatchling, setuptools, flit); emit **wheel** + **sdist** where appropriate. ### Native extensions - Use **cibuildwheel** or similar for manylinux/macOS/windows matrices --- ## Stage 5: Versioning & Tags **Goal:** Single source of truth for version (static in pyproject or dynamic from VCS); git tags match releases. --- ## Stage 6: Publish & CI **Goal:** PyPI **trusted publishing** (OIDC) preferred over long-lived API tokens in secrets. ### Practices - Test with TestPyPI when learning the flow - Restrict token scope and enable 2FA on PyPI accounts --- ## Final Review Checklist - [ ] src layout and imports verified in clean venv - [ ] pyproject metadata complete; console scripts work - [ ] Dependency policy documented (extras, bounds) - [ ] Artifacts build for intended platforms - [ ] Versioning aligned with tags; CI publishing secure ## Tips for Effective Guidance - Add `py.typed` for typed libraries (PEP 561). - Lazy-import heavy optional deps inside functions to keep CLI startup fast. - Namespace packages are easy to misconfigure—prefer one clear top-level package name. ## Handling Deviations - Monorepos: coordinate versions or use independent packages per folder with clear tooling. - Docker-only apps: still package for testability; Dockerfile installs the wheel.

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 python-packaging-1776028948 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 python-packaging-1776028948 技能

通过命令行安装

skillhub install python-packaging-1776028948

下载 Zip 包

⬇ 下载 python-packaging v1.0.0

文件大小: 2.17 KB | 发布时间: 2026-4-13 11:40

v1.0.0 最新 2026-4-13 11:40
Initial release of deep Python packaging workflow guidance.

- Covers stages from project layout to CI-based publishing for libraries and CLI tools.
- Emphasizes reproducible builds, proper metadata, dependency separation, and secure release practices.
- Includes best practices for backend selection, Python compatibility, and distribution artifacts.
- Final checklist and troubleshooting tips provided for reliable PyPI or private index releases.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部