1.setuptools简介
2.包格式
3.setup.py文件from setuptools import find_packages, setup
setup(
name="flaskr",
version="1.0.0",
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=[
"flask",
],
)
相关参数可以[查看](https://setuptools.readthedocs.io/en/latest/setuptools.html#metadata)
常用参数解释:
3.1. find_packages(where="",exclude=(),include=("*",))
上面的setup.py中使用的find_packages(),可以方便的为我们添加包不需要手动添加。默认搜索与setup.py同级目录下各个含有__init__.py的目录作为要添加的包。
3.2. include_package_data:
3.3manifest.in文件(与setup.py同级目录)include flaskr/schema.sql
graft flaskr/static
graft flaskr/templates
global-exclude *.pyc
3.4. zip_safe
3.5. install_requiresinstall_requires=[
"requests>=1.0",
"flask>=1.0"
]dependency_links = [
"http://packages.example.com/snapshots/foo-1.0.tar.gz",
"http://example2.com/p/bar-1.0.tar.gz",
]
4.本地测试安装
pip3 install -e .
5.构建发行文件
先安装好wheel库
pip3 install wheel
python3 setup.py bdist_wheel
6.发布包(简略)[distutils]
index-servers = pypi
[pypi]
username:xxx
password:xxx