pip install <package name>
pip的安装请前往:https://pip.pypa.io/en/stable/installing/
最近因为个人需求原因(其实就是因为代码没高光),发布了一个自己的pypi Python包,这里我大致分享如何发布自己的Pypi包一般过程。
python版本:3.7.5
相关模块:
setuptools 模块;
wheel 模块;
twine 模块;
import setuptools
## 读取本地markdown文件方便我们对我们的库吹牛逼。
with open("README.md", "r", encoding='utf-8') as fh:
long_description = fh.read()
setuptools.setup(
name="QcureUi", # 包名
version="0.0.2", # 版本号
author="Lux", # 作者笔名
author_email="[email protected]", # 作者邮箱
description="Used for pyqt5 beautification", # 发布包简单介绍
long_description=long_description, # 将我们吹牛逼的草稿写入包用法中
long_description_content_type="text/markdown", # 用法的读取格式为markdown格式
url="https://github.com/pypa/sampleproject", # 项目地址
packages=setuptools.find_packages(), # 包需要装哪些python文件,setuptools.find_packages()则为根目录下全部python文件
include_package_data=True, # MANIFEST.in文件允许导入
zip_safe=False, # 是否打入压缩包
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
], # 包的最低使用要求
install_requires= [
'pywin32'
], # 此包运行需要哪些其余的第三方库
project_urls={
'Blog': 'https://blog.csdn.net/qq_45414559/article/details/105560090',
}, # 介绍包的项目地址
)
include *.png
include *.json
include QcureUi/beautifyUi *.png
recursive-include QcureUi *.png *.json
具体格式和参数参考:https://docs.python.org/2/distutils/sourcedist.html
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.
我们在这里先配置一下pypi源的问题。不是pip下载源,而是pypi上传源的问题。
~/.pypirc,文件内容如下:
[distutils]
index-servers=pypi
[pypi]
repository = https://upload.pypi.org/legacy/
username = ***********
password = ***********
账号密码写入刚才让你们记住的就好了。保存文件退出!
下载一下我们的第三方库来看看吧:
pip install QcureUi