侧边栏壁纸
博主头像
可乐呢o3o博主等级

少些比较,多些谦虚。

  • 累计撰写 53 篇文章
  • 累计创建 67 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

python发布自己的包

liuker
2024-01-02 / 0 评论 / 0 点赞 / 44 阅读 / 2267 字

参考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
0

评论区