参考python的setuptools
setup.py中的配置参考
https://docs.python.org/3.11/distutils/apiref.html
from distutils.core import setup
setup(
name="pytos",
version="0.1",
packages=find_packages(),
description="file management module for hezheng",
author="Liuker Sun",
author_email="[email protected]",
url="",
install_requires=[
"esdk-obs-python",
"requests",
],
classifiers=[
"Development Status :: 1 - Alpha",
"Intended Audience :: Developers",
"Topic :: Software Development :: Build Tools",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
],
keywords="file management module for hezheng",
python_requires=">=3.10",
)
如果是包的话,需要在文件夹下创建 __init__.py
编译python的包
本质上是新建了一个build目录,而后将指定的packages列表包下的所有".py"文件拷贝过去
python setup.py build
将源文件进行打包操作
python setup.py sdist
将python打包成egg包或者whl包
本质上是一个zip文件,此处注意,setuptools是基于distutils进行封装的,但打wheel包时要从setuptools包导入setup模块。安装wheel pip install wheel
。
from setuptools import setup, find_packages
打包成whl
python setup.py sdist bdist_wheel --universal
评论区