将模块发布到 pip 和 PyPi [英] Publishing modules to pip and PyPi
问题描述
我使用 python 创建了一个模块.我想把它发布到pip 和 PyPi 以便其他人可以轻松下载和使用它.我该怎么做?
I have created a module using python. I want to publish it to pip and PyPi so that others can download and use it easily. How do I do it?
推荐答案
可以在 Internet 上轻松找到答案.我刚刚引用了这个网站 来回答你.您可以按照以下步骤操作:
The answer can be easily found on the Internet. I just referenced this site to answer you. You can follow the steps below:
在
PyPi
上创建一个帐户.
create an account on
PyPi
.
创建一个 README.md
文件作为用户说明(强烈推荐).
Create a README.md
file as an instruction for users (Highly recommended).
创建一个setup.cfg
文件,写入如下内容:
Create a setup.cfg
file, and write the following content:
[metadata]
description-file = README.md
通过引用本网站创建
LICENSE
文件.
正如@Yang HG 提到的,编写一个setup.py
文件,然后运行python setup.py sdist
.
As @Yang HG mentioned, write a setup.py
file, followed by running python setup.py sdist
.
使用 twine
上传您的发行版.首先,您需要pip install twine
,然后运行twine upload dist/*
.
Upload your distribution by using twine
. First, you need to pip install twine
, then run twine upload dist/*
.
最后,您的发行版可以在 https://pypi.org/project/YOURPACKAGENAME/
Finally, your distribution can be viewed on https://pypi.org/project/YOURPACKAGENAME/
这篇关于将模块发布到 pip 和 PyPi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!