-
Notifications
You must be signed in to change notification settings - Fork 9
Uploading to PYPI
Overview: This guide is to help assist in uploading a package to PyPi. There are plenty of guides online in order to assist you but this is what worked for me. Just a word of caution the PyPi site recently got updated and even their documentation did not work correctly. This guide is based on the guide that you can find here: https://packaging.python.org/tutorials/packaging-projects/ but I will start from the beginning. Lastly, I am assuming that you know how to setup a python package, a python setup.py file, README.md file, and a license file. If not then please google how to do this, because that will not be covered in this guide.
Step-1: You will need some type of environment, and I use Anaconda for simplicity. It is a pain to setup and not quick at all but it gets the job done. I know that the python version of their environments is a little quicker and for this purpose this might be the route that you will want to take. So, go to the following site for a great explanation of how to start an environment: https://packaging.python.org/guides/installing-using-pip-and-virtualenv/.
Step-2: Make sure that the environment is activated and that you have installed and updated the following:
- Type: python3 -m pip install --user --upgrade setuptools wheel twine
Step-3: Now it is time to pip package the package.
- Type: python3 setup.py sdist bdist_wheel
- Everything will be stored in the quest/dist/ folder.
Step-4: Go to your home directory and create the following file:
- Filename .pypirc
- Contents:
[distutils]
index-servers =
pypi
[pypi]
repository:https://upload.pypi.org/legacy/
username: <username>
password: <password>
Step-5: Now there are two sites that you can upload your package too. There is the main index and the testing index. For this tutorial I will be uploading to the main index. Please make sure that the package that you want to upload does not already have its name taken by someone else on the main index, a simple search should answer this question. Lastly, make sure that your environment is activated before doing the following:
- Type: python -m twine upload dist/*