Here's what I struggled with when I first registered my own package on PyPI the other day. The first thing I'm addicted to is that you need to use twine, the package name is not appropriate.
Initially, I searched and looked up how to register a package on PyPI, and many blogs and articles showed the following steps.
no | work | Reference url/command |
---|---|---|
1 | Source code creation | |
2 | Arrange the folder structure | Python:Include data files in your own package |
3 | setup.Create py | PyPI registration steps for those who want to make a PyPI debut |
4 | Distribution construction | >>python setup.py sdist |
5 | Test installation | >>python setup.py install |
6 | Create an account on PyPI for test | Registration destination |
7 | .Create pypirc | Register as a package on PyPI |
8 | Register the package name | >>python setup.py register -r pypitest |
9 | Upload package | >>python setup.py sdist upload -r pypitest |
10 | Create an account on production PyPI | Registration destination |
11 | Register the package name | >>twine register dist/* |
12 | Upload package | >>twine upload dist/* |
13 | Test installation | >>pip install package name |
Twine, PyPi for test, ".pypirc" related is supplemented.
-You need to create separate accounts for test PyPi and production PyPi. -".Pypirc" is required when using twine. -For Windows, the location to put ".pypirc" is the location specified by the environment variable (c: \ Users \ foo \ .pypirc if HOMEPATH = \ Users \ foo) -If server is defined in ".pypirc", write the server name defined in ".pypirc" in the url specification of python setup.py -r.
sample
file:.pypirc
[distutils]
index-servers =
pypi
pypitest
[pypi]
repository: https://pypi.python.org/pypi
username: worst
password: Salary_burglar
[pypitest]
repository: https://testpypi.python.org/pypi
username: learner
password: Being_late
#If the server definition is pypitest, specify as follows
>>python setup.py register -r pypitest
>>python setup.py sdist upload -r pypitest
It went smoothly until I registered with PyPI for test. If you have a long history of Python, it will take less than 5 minutes. When I registered the package name on the PyPI production server, I got the following error and stopped.
Server response (410): This API is no longer supported, instead simply upload the file.
It seems that you can use twine instead of python setup.py register, or register PKG-INFO directly with the following url.
https://pypi.python.org/pypi?%3Aaction=submit_form
sample
#Old way
python setup.py register
python setup.py sdist upload
#New way
pip install twine #Install if necessary
twine register dist/*
twine upload dist/*
It was around 2014 that this method became recommended (it is now required because it is no longer supported)? So, the articles up to 2014 are introduced in the old way.
And while PyPi for test can be registered with the old method, PyPi for production can only be registered with the new method, which is the easiest place to get hooked.
This is simple. The package name you were trying to register was already in use by someone else. In the response, I immediately noticed that it could not be specified if it was already in use, but ... is a later festival.
When I try to register PKG-INFO on the WEB with a used name, the following response is returned.
Forbidden You are not allowed to store 'picker' package information
When I use twine, I get the following message:
HTTPError: 403 Client Error: You are not allowed to edit 'picker' package information for url: https://pypi.python.org/pypi
Check the batting by searching on the PyPi site, or
https://pypi.python.org/pypi
Search for "pip search the name you want to use".
If you have any, please use "pip search *> list.txt" to get the full list and stare at it.
Recommended Posts