What is the PyPI
和Mvn的仓库平台类似,PyPI(Python Package Index) 是 Python 官方的第三方软件包仓库, 相当于 Python 的 “应用商店”。
- 网址:https://pypi.org
How to publish you whl package
- 注册自己的帐号,申请API KEY
- 配置自己项目中的pyproject.toml
[project]
name = "mypackage"
version = "0.1.0"
description = "A simple example package"
readme = "README.md"
license = {text = "MIT"}
authors = [{name = "Your Name", email = "your@email.com"}]
dependencies = []
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
- 安装打包用的软件
pip install build - python -m build
python -m build
dist/
├── mypackage-0.1.0.tar.gz
└── mypackage-0.1.0-py3-none-any.whl
mypackage-0.1.0.tar.gz — 源代码分发包(Source Distribution,简称 sdist)
mypackage-0.1.0-py3-none-any.whl — 预编译的 Wheel 包(Binary Distribution)
- 上传
pip install twine twine upload dist/*