Last active
September 24, 2022 02:20
-
-
Save brccabral/791f19b0d08da572778bb14fa49ab209 to your computer and use it in GitHub Desktop.
Upload a Python package to Pypi.org
Register in https://test.pypi.org/
Register in https://pypi.org/
The structure of your folders should be
package_location/
|____setup.py ('name' is your project-name and should be unique within pypi.org)
|____package_name/
|____ __init__.py
|____ module1.py
|____ module2.py
|____ license.txt (example https://opensource.org/licenses/MIT)
|____ README.md
|____ setup.cfg
Install twine
pip instal twine
Enter package_location/, where you have setup.py, not where your code is, and run sdist command in the setup file
cd package_location
python setup.py sdist
It will create two folders, dist/ and project_name.egg-info/
Upload to test.pypi. It will ask for your user and password
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
To install a package from test.pypi, add the its url
pip install -i https://test.pypi.org/simple/ project-name==x.y
To use it:
import package_name # or
from package_name import *
To upload to pypi.org:
twine upload dist/*
with user and password
Then,
pip install project-name
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment