Upload distribution to PyPI
Environment
- MacOS Catalina 10.15.7
- Python 3.9.7
Directory structure:
|
|
Register PyPI account
- PyPI https://pypi.org/
- PyPI(test) https://test.pypi.org/
Email confirmation is required for each environment.
create ~/.pypirc
~/.pypirc
|
|
Install wheel and twine
- wheel : A built-package format for Python
- twine : Collection of utilities for publishing packages on PyPI
|
|
Revisit setup() keywords
I have already made setup.py
when managed package dependency and configured tox.
Refering setuptools | New and Changed setup() Keywords, updated version
and keywords
setup.py
|
|
Create package
Before creating package, it might be better to clean up .egg-info
and dist
directory that was created last time.
|
|
Create distribution
|
|
dist/concurrent-api-client-0.0.1.tar.gz
is created.
Create library packages
|
|
Modules are located to build/lib
and lib/concurrent-api-client-0.0.1-py3-none-any.whl
is created.
Upload distribution
Upload to test.pypi.org
|
|
When upload completed, you can check https://test.pypi.org/project/"package-name"/
e.g. https://test.pypi.org/project/concurrent-api-client/
Uplodad to pypi.org
|
|
When upload completed, you can check https://pypi.org/project/"package-name"/
e.g. https://pypi.org/project/concurrent-api-client/
Install package
Install from test.pypi.org
|
|
Install from pypi.org
|
|
Trouble shooting
1. twine failed by HTTPError: 403 Forbidden
While I could upload to test.pypi.org
, failed to upload to pypi.org
by 403 Forbidden error.
|
|
The cause is python_api_client
is not reserved in test.pypi.org but in pypi.org.
I changed the package name to concurrent-api-client
that is not reserved. (Some document project name is replaced accordingly)
2. package dependency version unmatched
When installing the package, sometime it fails by
|
|
- test.pypi.org, repository has less than
3.0.0a1
(does not have3.0.1
) Ref. https://test.pypi.org/project/pyparsing/#history - pypi.org, repository has less than
3.0.2
Ref. https://pypi.org/project/pyparsing/#history
I check the versions in production pypi.org and specifies the ver. number in requirements.txt.
Sources
See finalized codes(tox.ini
and setup.py
) in github