[Python]上传huanyuan包到pypi
前言
由于国内通过pip下载python包的速度真的很慢,很容易因为超时而失败,而pqi可以把PyPi源迅速切换为国内源tuna, douban, aliyun, ustc从而大大加快python包的安装速度。
huanyuan是对pqi的修改版本,添加类似python -m HUANYUAN.huanyuan
的模块方式访问模块,解决某些情况下安装pqi后在命令行显示无此命令或者修改指定版本Python的下载源.
修改
原作地址(MIT协议):https://github.com/yhangf/PyQuickInstall
修改(MIT协议):https://gitee.com/qsbye/python-huanyuan
主要修改setup.py
from setuptools import setup, find_packages
VERSION = '3.0.2'
with open("README.md", "r", encoding="utf-8") as fp:
long_description = fp.read()
setup(name='huanyuan', #换源,文化自信,使用拼音
version=VERSION,
description="Fast switching PyPi mirror image source",
classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
keywords='python、PyPi source、terminal',
author='Original:HangfengYang,Edited by qsbye',
author_email='yhf5fhy@gmail.com,2557877116@qq.com',
url='https://gitee.com/qsbye/python-huanyuan',
license='MIT',
packages=find_packages(),
long_description=long_description,
long_description_content_type="text/markdown",
include_package_data=True,
zip_safe=True,
install_requires=[
'docopt',
],
entry_points={
'console_scripts':[
'huanyuan = HUANYUAN.huanyuan:main'
]
},
# 添加以下内容
package_dir={'huanyuan': 'HUANYUAN'},
py_modules=['huanyuan'],
)
生成wheel
[https://zhuanlan.zhihu.com/p/261579357]
setuptools是python自带的用来构建包的工具,构建出来的wheel(.whl)可供其他人pip install和import。
cd 模块目录
pip install -U pip setuptools wheel
pip wheel . --trusted-host pypi.douban.com
上传pypi
[https://blog.csdn.net/jimo_lonely/article/details/111501357]
pypi官网
首先要注册个账号,
然后安装twine,
pip install twine
python -m twine upload ./PyQuickInstall/pypi/packages/huanyuan-3.0.2-py3-none-any.whl
#会要求输入账号和密码
结果:
[https://pypi.org/project/huanyuan/3.0.2/]
效果对比
python3 -m pip install -i https://pypi.org huanyuan
python3 -m PQI.pqi #失败
python3 -m HUANYUAN.huanyuan #成功