How To Install twine on Ubuntu 18.04

In this tutorial we learn how to install twine on Ubuntu 18.04. twine is utility for interacting with PyPI

Introduction

In this tutorial we learn how to install twine on Ubuntu 18.04.

What is twine

twine is:

Twine is a tool for uploading distributions (in the Python meaning) to PyPi.

Why should twine be used over the traditional approach?

The biggest reason to use twine is that python setup.py upload uploads files over plaintext. This means anytime you use it you expose your username and password to a MITM attack. Twine uses only verified TLS to upload to PyPI protecting your credentials from theft.

Secondly it allows you to precreate your distribution files. python setup.py upload only allows you to upload something that you’ve created in the same command invocation. This means that you cannot test the exact file you’re going to upload to PyPI to ensure that it works before uploading it.

Finally it allows you to pre-sign your files and pass the .asc files into the command line invocation (twine upload twine-1.0.1.tar.gz twine-1.0.1.tar.gz.asc). This enables you to be assured that you’re typing your gpg passphrase into gpg itself and not anything else since you will be the one directly executing gpg –detach-sign -a .

Features:

  • Verified HTTPS Connections
  • Uploading doesn’t require executing setup.py
  • Uploading files that have already been created, allowing testing of distributions before release
  • Supports uploading any packaging format (including wheels).

There are three methods to install twine on Ubuntu 18.04. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install twine Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install twine using apt-get by running the following command:

sudo apt-get -y install twine

Install twine Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install twine using apt by running the following command:

sudo apt -y install twine

Install twine Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install twine using aptitude by running the following command:

sudo aptitude -y install twine

How To Uninstall twine on Ubuntu 18.04

To uninstall only the twine package we can use the following command:

sudo apt-get remove twine

Uninstall twine And Its Dependencies

To uninstall twine and its dependencies that are no longer needed by Ubuntu 18.04, we can use the command below:

sudo apt-get -y autoremove twine

Remove twine Configurations and Data

To remove twine configuration and data from Ubuntu 18.04 we can use the following command:

sudo apt-get -y purge twine

Remove twine configuration, data, and all of its dependencies

We can use the following command to remove twine configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge twine

References

Summary

In this tutorial we learn how to install twine package on Ubuntu 18.04 using different package management tools: apt, apt-get and aptitude.