我应该如何向 PyPI 注册一个包? [英] How am I supposed to register a package to PyPI?

查看:23
本文介绍了我应该如何向 PyPI 注册一个包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

打包和分发 Python 包的文档中,它说要使用 twinerepository = https://upload.pypi.org/legacy/.pypirc 中.现在这个 URL 既是——从它的最后一点来看——既是一种传统的做事方式,又是一种不存在的方式:

In the documentation for packaging and distributing Python packages, it says to use twine with repository = https://upload.pypi.org/legacy/ in .pypirc. Now this URL is both – from the last bit of it – a legacy way to do things, and a non-existing one at that:

$ twine register dist/scriptdoctest-0.1-py2.py3-none-any.whl 
Registering package to https://upload.pypi.org/legacy/
Enter your username: MyUserName
Enter your password: 
Registering scriptdoctest-0.1-py2.py3-none-any.whl
HTTPError: 410 Client Error: This API is no longer supported, instead simply upload the file. for url: https://upload.pypi.org/legacy/

现在使用 scriptdoctest.egg-info/PKG-INFO 是注册软件包的首选和唯一方法,还是有其他方法可以使用 twine还是其他一些 CLI 工具?

Is using scriptdoctest.egg-info/PKG-INFO now the preferred and only way to register a package, or is there some other way to do this with twine or some other CLI tool?

推荐答案

https://packaging.python.org/distributing/ 实际上提供了所有必要的信息.

https://packaging.python.org/distributing/ actually provides all necessary information.

  1. 创建一个有效的项目,尤其是setup.py
  2. python setup.py sdist bdist_wheel
  3. 确保您拥有正确的 ~/.pypirc 以及来自 https 的凭据://pypi.python.org/pypi
  4. twine upload dist/* - 不再需要/可以注册
  1. Create a valid project, especially setup.py
  2. python setup.py sdist bdist_wheel
  3. Make sure you have a correct ~/.pypirc with your credentials from https://pypi.python.org/pypi
  4. twine upload dist/* - it is no longer necessary/possible to register

我的.pypirc如下所示:

[distutils]
index-servers =
  pypi
  pypitest

[pypi]
repository=https://pypi.python.org/pypi
username=Martin.Thoma
password=[your password]

[pypitest]
repository=https://testpypi.python.org/pypi
username=Martin.Thoma
password=[your password]

这篇关于我应该如何向 PyPI 注册一个包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆