Packaging connects source to installable artifacts. Prioritize reproducible builds, accurate dependencies, and safe automated releases.
Trigger conditions:
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.
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.
Goal: pyproject.toml with PEP 621 metadata; [project.scripts] or [project.gui-scripts] for CLIs.
Goal: Separate runtime deps from optional extras (dev, docs, speedups); pin strategy differs for libraries vs applications.
Goal: Choose build backend (hatchling, setuptools, flit); emit wheel + sdist where appropriate.
Goal: Single source of truth for version (static in pyproject or dynamic from VCS); git tags match releases.
Goal: PyPI trusted publishing (OIDC) preferred over long-lived API tokens in secrets.
py.typed for typed libraries (PEP 561).7w4.net小葱技能站收录全网优质技能,值得收藏。
这个 Skill 质量中上,结构清晰、条理分明,能帮助开发者建立完整的 Python 打包知识框架,包含不少实用的最佳实践建议。不过内容相对理论化,缺乏具体示例和操作细节,对于想直接动手的用户来说可能稍显空洞,深度有待加强。