主要是参考下面几篇博客
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/*