Installing CLI Tools Using ‘dephell’
Tags: python, devops, deployment, dephell
Published: 2020-03-13 06:45:56

---
title: Installing CLI Tools Using ‘dephell’
published: true
date: 2020-03-03 06:00:00 UTC
tags: python, devops, deployment, dephell
series: Developer Tools That Simplify Your Life
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/qvnj3pn21ylfhzul575s.png
canonical_url: https://jhermann.github.io/blog/python/deployment/2020/03/03/install_tools_with_dephell.html
---
> *Taking a closer look at Dephell's ‘jail’ sub-command to replace ‘pipsi’.*

## Introduction

‘dephell’ is a useful add-on tool for project and venv management that works with existing standard tooling, instead of doing a bad _replacement_ job like so many others. It is available on GitHub.

{% github dephell/dephell no-readme %}

This post takes a look at how it can take over from `pipsi` (Python Script Installer, which is unmaintained) to manage _isolated_ tool installations by providing each tool with its own virtual environment.

## Installation

Dephell is installed via a Python installer script into its own venv (compatible to what `dephell` itself creates as a so-called ‘jail’).

```shell
curl -L dephell.org/install | python3

```

`dephell` needs at least Python 3.6, which is the default on Ubuntu Bionic, so it _just works_™ there. On _Xenial_, you need to install 3.6+ from the Deadsnakes PPA first, and pipe the installer script into e.g. `python3.8`.

The only locations touched by the installer on a Posix host are `~/.local/bin/` and `~/.local/share/dephell/venvs/`.

## Going into ‘jail’

As already mentioned, this post will take a deeper look into the `dephell jail` sub-command for venv management.

Unlike `pipsi`, the former go-to tool for that purpose, it is maintained, supports full life-cycle management (i.e. it has a way to remove tool installations), and also supports projects that have several console entry points (i.e. expose more than one command).

I also like it a lot more than `pipx`, which has a similar feature profile when compared to just dephell's `jail` sub-command, but YMMV.

As a first example, to get rid of `dephell` again, just remove it using itself:

```shell
dephell jail remove dephell

```

Note that doing so leaves anything installed via dephell untouched (i.e. other jails still work), and reinstalling allows to manage those again.

Adding more tools is done using `jail install`:

```
dephell jail install shiv
shiv --version

```

Make sure that `~/.local/bin` is in your `PATH`, which is not always the case on older GNU/Linux releases.

You can easily list what you have installed:

```console
$ dephell jail list
{
  "dephell": [
    "dephell"
  ],
  "shiv": [
    "shiv-info",
    "shiv"
  ]
}

```

As you can see, the output is JSON by default and lists all installed tools with their possibly multiple entry points. You can add the `--table` option to get output more suited for humans.

To see more details about a single venv, use `jail show`:

```console
$ dephell jail show dephell
{
  "entrypoints": [
    "dephell"
  ],
  "name": "dephell",
  "path": "/home/jhe/.local/share/dephell/venvs/dephell",
  "size": {
    "lib": "43.21Mb",
    "total": "56.78Mb"
  },
  "version": "0.8.1"
}

```

Finally, there is a `jail try` command to give new tools a quick spin in a _temporary_ environment, without leaving any trace of it on your machine.

```
$ dephell jail try --command "pip --version" pip
…
INFO running...
pip 20.0.2 from /tmp/tmpnm5gvieo/lib/python3.6/site-packages/pip (python 3.6)
```

## Beyond ‘jail’

Besides `jail`, there are lots of other sub-commands for dependency management, handling docker images, creating common Python software project files, managing and vendoring your project's dependencies, and handling of project-specific venvs. See the full [DepHell documentation](https://dephell.readthedocs.io/) for details on that.