Ref:
https://johnfraney.ca/posts/2019/05/28/create-publish-python-package-poetry/
第一步:注册pypi.org和test.pypi.org的用户,注意他们俩是不通用的
第二步:修改项目的pyproject.toml文件,例如(https://gitee.com/waketzheng/aiopathlib.git):
[tool.poetry]
name = "aiopathlib"
version = "0.1.0"
description = "Pathlib support for asyncio"
authors = ["Waket Zheng <waketzheng@gmail.com>"]
license = "MIT"
readme = "README.rst"
homepage = "https://github.com/waketzheng/aiopathlib"
repository = "https://github.com/waketzheng/aiopathlib"
keywords = ["aiopathlib", "asyncpath", "aiopath"]
classifiers = [
"License :: OSI Approved :: MIT License",
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3 :: Only",
"Operating System :: POSIX",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
"Framework :: AsyncIO",
]
include = [
"LICENSE",
]
[tool.poetry.dependencies]
python = "^3.8"
aiofiles = "^0.7.0"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
第三步:发布前测试配置是否如预期
poetry build
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry publish -r testpypi # 注:README.rst会报错,README.md则不会
pip install --index-url https://test.pypi.org/simple/ your-package-name
第四步:发布到pypi
poetry publish