Python 包发布

包结构

在这里插入图片描述

准备工作

  1. twine 安装

    pip3 install twine
    
  2. pypi 账号注册 https://pypi.org/account/register/, 注册成功后,记得到邮箱激活,否则无法使用

    密码必须是字母加数字

三个文件

  1. setup.py

    import setuptools
    
    with open("README.md", 'r', encoding='utf-8') as f:
        long_description = f.read()
    
    with open("requirements.txt", 'r', encoding='utf-8') as f:
        requirements = f.read().split()
    
    setuptools.setup(
        name="air-df",  					# pip install name
        version="0.0.7",					# 版本,每次更新需修改,否则无法上传
        author="Damon",
        author_email="527439@qq.com",
        description="常用插件",
        long_description=long_description,
        long_description_content_type="text/markdown",
        url="https://github.com/Air-df",  	# git-hup 项目地址, 这里只放了主页地址,这个参数不重要
        packages=['air'],					# 文件夹名
        install_requires=requirements,  	# 依赖库,发布后,pip install过程中自动安装该参数下的依赖
        classifiers=[
            "Programming Language :: Python :: 3.9",
            "License :: OSI Approved :: MIT License", 
            "Operating System :: OS Independent",
        ],
        py_modules=[						# 打包的具体文件
            'air.base_handler', 'air.plugins'
        ]
    )
    

2.README.md

关于包的介绍

3.LICENSE

证书文件,自己新建,拷贝下面到文件里就ok

Copyright (c) 2018 The Python Packaging Authority

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

两个命令

在包根目录下执行

  1. 打包
    python setup.py sdist bdist_wheel
    
  2. 发布到pypi – 需要账号、密码
    python -m twine upload dist/*
    

完事儿

安装调用
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值