How To Install snakefood on Ubuntu 18.04

In this tutorial we learn how to install snakefood on Ubuntu 18.04. snakefood is Python dependency grapher

Introduction

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

What is snakefood

snakefood is:

Generate dependency graphs from Python code. This dependency tracker package has a few distinguishing characteristics:

  • It uses the AST to parse the Python files. This is very reliable, it always runs.
  • No module is loaded. Loading modules to figure out dependencies is almost always problem, because a lot of codebases run initialization code in the global namespace, which often requires additional setup. Snakefood is guaranteed not to have this problem (it just runs, no matter what).
  • It works on a set of files, i.e. you do not have to specify a single script, you can select a directory (package or else) or a set of files. It finds all the Python files recursively automatically.
  • Automatic/no configuration: your PYTHONPATH is automatically adjusted to include the required package roots. It figures out the paths that are required from the files/directories given as input. You should not have to setup ANYTHING.
  • It does not have to automatically ‘follow’ dependencies between modules, i.e. by default it only considers the files and directories you specify on the command-line and their immediate dependencies. It also has an option to automatically include only the dependencies within the packages of the files you specify.
  • It follows the UNIX philosophy of small programs that do one thing well: it consists of a few simple programs whose outputs you combine via pipes.

This package will install the following programs:

  • sfood - detect import statements using the AST parser
  • sfood-checker - check for superfluous import statements in Python source code
  • sfood-cluster - read snakefood dependencies from stdin and cluster according to filenames
  • sfood-copy - read a snakefood dependencies file and flatten and output the list of all files
  • sfood-flatten - read a snakefood dependencies file and flatten and output the list of all files
  • sfood-graph - read snakefood dependencies and output a visual graph
  • sfood-imports - parse Python files and output a unified list of imported symbols

There are three methods to install snakefood 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 snakefood Using apt-get

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

sudo apt-get update

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

sudo apt-get -y install snakefood

Install snakefood Using apt

Update apt database with apt using the following command.

sudo apt update

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

sudo apt -y install snakefood

Install snakefood 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 snakefood using aptitude by running the following command:

sudo aptitude -y install snakefood

How To Uninstall snakefood on Ubuntu 18.04

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

sudo apt-get remove snakefood

Uninstall snakefood And Its Dependencies

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

sudo apt-get -y autoremove snakefood

Remove snakefood Configurations and Data

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

sudo apt-get -y purge snakefood

Remove snakefood configuration, data, and all of its dependencies

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

sudo apt-get -y autoremove --purge snakefood

References

Summary

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