MakePip – Automatically Publish Python to PyPi

  • Home /
  • MakePip – Automatically Publish Python to PyPi

Automatically Publish your Python applications to the Python Package Index (PyPI) for use through Pip.

If you have ever needed to publish your python scripts to Pypi, you will know of all the work required to do so.

Makepip takes all the effort away by providing a command-line tool to automatically do all the heavy lifting for you.

How to install

If you are running Python3, then all you need to do is pip install makepip

If you are running Python2, then you will need to run Python3, you can do this by adding a virtual environment.

We recommend getting started with a Python Virtual Environment first so that everything always works as expected.

virtualenv -p python3 venv
source venv/bin/activate

Now you can install makepip directly

pip install makepip

At this stage, you are all setup and ready to go!

A quick tutorial

Start by heading over to your Git source control tool, we recommend Github, start by creating a blank repository . This is where your code will be stored in the end.

Fill in the name of your repository; we have chosen hitherecli and left everything else as is. Click Create repository when done.

Back in the command-line, create a directory for our tutorial:

mkdir -p ~/src/hitherecli && cd $_

In this directory, create a file called hitherecli.py and put the following code in it:

def main():
    print("hi there cli")

This is the code that we will package and push to Pypi in this tutorial.

Now let’s quickly get a python virtual environment going before we continue and then also install makepip.

virtualenv -p python3 venv
source venv/bin/activate
pip install makepip

At this stage, we are now able to run makepip from the command-line.

The input steps are currently as follows. Fill them out by providing your own specifics:

Input FieldDescription
Pip name:hitherecli
Description:Saying hi from the cli
Author name:Your name
Author website:https://ataiva.com (should be your own website)
Author email:[email protected] (should be your own email address)
Git repository:https://github.com/ao/hitherecli
Python script:the absolute path to the script we created: /Users/ao/src/hitherecli/hitherecli.py
Pypi username:this will be aoms for me (should be your own username)

At this stage, the script will run and perform various actions.

It will pause when it requires you to enter your password for uploading the python package to Pypi.

Once the makepip script has completed, you will see that it has pushed the files and the command-line says:

This indicates success, and our packages are now available at:

https://pypi.org/project/hitherecli/ and https://github.com/ao/hitherecli

Final testing

To test this actually worked, open a new command-line window and type pip3 install hitherecli.

This will install our newly packaged python code from Pypi.

All that is left to do now is type hitherecli and see the results for ourselves!