[Python]上传huanyuan包到pypi
Posted qsBye
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[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 #成功
基于Python自动上传包到nexus仓库
1.设计思路
用户通过excel表格的形式填写包的信息,并将包一起发送给负责人
2.代码实现
#coding:utf8 import os import xlrd def GetData(fileName): data = xlrd.open_workbook(fileName) table = data.sheets()[0] nrows = table.nrows - 4 #删除后4行 startrow = 3 #过滤前三行 endrow = nrows rowlist = [] for i in range(startrow,endrow): rowlist.append(table.row_values(i,1,7)) #print(rowlist) return rowlist def Deploy(data): for line in data: #print(line) if line[0] == ‘‘: pass else: try: jar = ‘-Dfile=‘ + jarpath + line[0].strip() groupId = ‘ -DgroupId=‘ + line[3].strip() artifactId = ‘ -DartifactId=‘ + line[4].strip() version = ‘ -Dversion=‘ + str(line[5]).strip() jartype = ‘ -Dpackaging=jar‘ deployid = ‘ -DrepositoryId=release‘ repourl =‘ -Durl=http://xxxxx/repositories/maven-releases‘ shellCMD = "mvn deploy:deploy-file -Dmaven.test.skip=true " shellARG = jar + ‘ ‘ + groupId + artifactId + version +jartype + deployid +repourl os.system(shellCMD + shellARG) #print(shellCMD + shellARG) except: print(‘error‘) if __name__ == ‘__main__‘: jarpath = "jar\" fileName = u‘xxxxx.xlsx‘ data = GetData(fileName) #print(data) Deploy(data)
以上是关于[Python]上传huanyuan包到pypi的主要内容,如果未能解决你的问题,请参考以下文章
如何把一个 Python 项目发布到 PyPI 上指南教程 All In One
记录 Poetry 发布包到 pypi 遇到的坑:No suitable keyring backends were found