Python 包制作,布包制作,Python 包制作


Python 包制作

官方文档

Python 包目录

/package_parent_folder/package/__init__.py

在__init__.py文件内添加name = package,其中package指的是包名

在package_parent_folder下添加包文件setup.py、LICENSE、README.md文件。

LICENSE: 包许可说明

README.md: 包说明文件

setup.py: 包安装设置文件

设置文档

设置项文档

安装Python包制作依赖

setuptoolswheel

制作Python包

python3 setup.py sdist bdist_wheel

? 生成文件:

/distpackage-yourname-version-*.whlpackage_yourname-version-*.tar.gz

上传Python包

安装上传依赖

twine

Test Pypi

注册账号测试网站上传
> python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
下载测试
python3 -m pip install --index-url https://test.pypi.org/simple/ example-pkg-your-username

PyPi上传

注册账号上传
twine upload dist/*

报错:invalid command ‘bdist_wheel‘

安装wheel

Python 包制作

评论关闭