Your application can now be distributed as a Python package. If you’re working on Open Source use PyPI to distribute it but if this is an internal or just generally private package you’ll need to setup a private package server or use something like the service discussed here which is called Gemfury.
While there are simpler methods of getting access to an application such as cloning a repository they usually fall short when dealing with dependencies, including required files and environment management.
You can find the source for this post here.
This is a followup post from Python CLI Application. If you haven’t read it and you’d like to follow along then please clone the project.
Always version control your projects. Let’s initialize this as a git project if
you haven’t done so already, create a
.gitignore file and commit our current
Because we’re going to publish this package we’ll need to have better information in our setup script. Here’s how it should look:
Private Package Repository
If you haven’t done so initialize your project as a git repository with
Add and commit your code at least locally. We’ll need git for the following steps.
- Create an account at Gemfury
- Add fury as remote
- Push to Fury
git push fury master. You’ll need to authenticate.
You can now install packages with
pip using something like:
Optional: You can also enable Gemfury as a source by adding the following line to your
This instructions are from the official Getting Started Guide which should be at or near your dashboard. Make sure you get the relevant link with your account’s token there.
Public Package Repository
The following steps have been taken from the official PyPI guide.
pip install twine
- Create a Source Distribution with
python setup.py sdist
- Create Wheels universally if compatible
python setup.py bdist_wheel --universal
- Create an account at PyPI
- Create a
- Add the following information to your
- Finally upload your package with
twine upload dist/*
- There is a bug that will keep you from uploading a package you have removed discussed here
You can now install this package through any other session with
pip install fibocli
We have managed to publish our package to both a public and private package repository. This is very powerful as both methods are compatible with version control and collaboration. If you are interested in better control over the private package repository you can host your own with mypypi and there is also s3pypi to host packages on S3 with an excellent article about setting it up here.