Friedrich Ewald My Personal Website

Setting up PIP and PyPi on Mac OS

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.


About the author

is an experienced Software Engineer with a Master's degree in Computer Science. He started this website in late 2015, mostly as a digital business card. He is interested in Go, Python, Ruby, SQL- and NoSQL-databases, machine learning and AI and is experienced in building scalable, distributed systems and micro-services at multiple larger and smaller companies.