基于pyproject.toml的python项目配置与发布

pyproject.toml

[build-system]
requires = [
    "setuptools",
    "setuptools-scm",
    "wheel",
]
build-backend = "setuptools.build_meta"

[project]
name = "hogwarts_utils"
authors = [
    { name = "霍格沃兹测试开发学社" },
]
description = "日志、文件、路径等通用功能的封装"
readme = "README.md"
requires-python = ">= 3.9"
dynamic = ["version", "dependencies"]

[project.urls]
Homepage = "ceshiren.com"

[tool.setuptools]
packages.find.where = ["src"]

[tool.setuptools.dynamic]
dependencies = { file = ["requirements.txt"] }

文件包含规则 MANIFEST.in

exclude **/tests/**

发布

可以项目的bin目录下设置

cd $(dirname $BASH_SOURCE)/../
pwd
rm dist/*
python -m build
# twine upload dist/*
# twine upload -r ceba dist/*