Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How am I supposed to register a package to PyPI?

Tags:

python

pypi

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/

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?

like image 670
Anaphory Avatar asked Oct 13 '16 13:10

Anaphory


People also ask

What are the two requirements to register a package to PyPI?

In order to prepare your package for publication on PyPI, you need to provide some information about it. In general, you need to specify two kinds of information: Configuration of your build system. Configuration of your package.

How do I use PyPI packages?

Installing Python pip on your system allows you to manage PyPI packages easily. Many of these packages can be installed just by typing python -m pip install <package-name> into a terminal or command-line. Newer versions of Python 3 (3.4 and higher) and Python 2 (2.7. 9 and higher) come preloaded with pip.


1 Answers

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

TL;DR

  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

My .pypirc looks as follows:

[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]
like image 197
Martin Thoma Avatar answered Sep 29 '22 20:09

Martin Thoma