如何在PyPi发布自己的包

主要是参考下面几篇博客
https://blog.csdn.net/mouday/article/details/80736312
https://blog.csdn.net/mouday/article/details/79611454
https://www.ucloud.cn/yun/38501.html
https://www.cnblogs.com/yixianclove/p/7776792.html
然后总结下自己遇到的一些问题
1、首先是在https://pypi.org上注册账号
2、配置账号信息,我在上传包的时候一直无法输入密码,采用下面的方法完美解决
在用户目录(.\user\uname)下新建一个空白文件命名为.pypirc
.pypirc文件写入配置信息:

[distutils]
index-servers=pypi

[pypi]
repository = https://upload.pypi.org/legacy/
username = jin_tmac
password = xxxxxx

windows如果新建不了文件,可以先新建一个 新建文本文档.txt,通过rename修改名称ren 新建文本文档.txt .pypirc

3、然后就是创建包文件,包括以下:readme.md、 LICENSE、setup.py和你的核心代码包 ,这个打包的过程主要以上面第一个链接为主。
其中

setuptools.setup(
    name="chinesename",
    version="0.0.8",
    author="Peng Shiyu",
    license = 'MIT License',  
    author_email="pengshiyuyx@gmail.com",
    description="get a chinesename by random",
    long_description=long_description,
    long_description_content_type="text/x-rst",
    url="https://github.com/mouday/chinesename",
    packages=setuptools.find_packages(),
    classifiers=(
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
    ),
    install_requires = install_requires,       # 常用

上面的name就是整个project 也就是以后要import 的名字,要注意在pypi中没有重复的,并且好像是不能有下划线_,要用-

4、发布包
在setup.py目录下运行命令行窗口

# 先升级打包工具
pip install --upgrade setuptools wheel twine

# 打包
python setup.py sdist bdist_wheel

# 检查
twine check dist/*

# 上传pypi
twine upload dist/*
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值