Setting up PIP and PyPi on Mac OS28 Mar 2019 by Friedrich Ewald
Setting up PIP
Pip can be mostly used out of the box. To configure a different repository the configuration file needs to be edited.
The configuration file should be stored in
~/Library/Application Support/pip/pip.conf according to this post. If the folder and file are not existing, simply create those and then define the extra repository as follows:
[global] extra-index-url = http://download.example.com
After this is done,
pip install ... will also look in the extra repository for the corresponding package.
Uploading to PyPi
Uploading your package to PyPi is quite simple with twine.
First, you need to package your python application as follows:
python setup.py sdist bdist_wheel
This generates a source package in the tar.gz format and a compiled wheel package. If the source code is pure Python, this package will be platform independent.
The following step is optional and tests the upload to the PyPi test repository:
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
As the next step this package needs to be uploaded which can be achieved as follows:
twine upload dist/*
That’s it. You can now see your package on PyPi.org. It is important to note that a version number cannot exist twice and cannot be updated. To do so, you have to manually delete the old version first.