正经的官网文档:https://packaging.python.org/tutorials/packaging-projects/
目录结构
- packaging_tutorial/
- example_pkg/
- init.py
- setup.py
- LICENSE
- README.md
- example_pkg/
生成发行包
python setup.py sdist bdist_wheel
这个命令会在dist/目录生成2个文件:
- dist/
- example_pkg_YOUR_USERNAME_HERE-0.0.1-py3-none-any.whl
- example_pkg_YOUR_USERNAME_HERE-0.0.1.tar.gz
上传发行包
先安装 twine: python3 -m pip install --user --upgrade twine
twine upload dist/example_pkg_YOUR_USERNAME_HERE-0.0.1.tar.gz
# 或者
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
按照提示输入用户名和密码就可以了