September 09, 2014

Matplotlib on mint 13

Today, I had a friend who needed to use matplotlib on our company linux boxes. We have some issues with out proxy server that rules python pip out. This mixed with python version and other dependencies lead me to write this small script, as a kind of configure script, for his code project.

The script deals with installing python3 and other prebuilt packages for ubuntu (mint) and then uses python3 build mechanisms & easy_install to add any remaining python egg dependencies.

The script source & listing:
#!/bin/sh
#
# This is the friendly python3 matplotlib installer script
# it checks for all matplotlib dependencies as pr. Sep 9 2014
# Any additions to the installer must be added by hand!
#
# If none of the dependencies are installed, the script will:
# 1. install prebuild ubuntu packages
# 2. Create a local dir for downloaded files
# 3. install dependencies by downloading these from various sources
# 3.a cython
# 3.b numpy, scipy
# 3.c
pyttk, six, tkinter, pip,matplotlib
# 4. remove the directory after installation
#
# john


# 1.
sudo aptitude install python3 python3-dev python3-setuptools python3-tk python3-cairo python3-cairo-dev libpng-dev
sudo aptitude install gfortran libopenblas-dev liblapack-dev
sudo easy_install3 -U distribute

# 2.
matlib=/tmp/matlib
[ -d $matlib ] && sudo rm -rf $matlib
mkdir $matlib && cd $matlib

# 3. Install dependencies, these vary and will change for furure releases!
# As the matplotlib we use in the dse require bleeding edge, we'll grap the latest stuff from the bleeding repositories

# 3.a
wget http://cython.org/release/Cython-0.20.2.tar.gz && tar -zxvf Cython-0.20.2.tar.gz && cd Cython-0.20.2/ && sudo python3 setup.py install && cd -

# 3.b
#install bleeding edge eggs from git repositories
for package in numpy scipy; do
    [ -d $package ] && sudo rm -rf $package
    git clone http://github.com/$package/$package.git $package && cd $package && sudo python3 setup.py install && cd -
done

# 3.c
# install bleeding edge eggs using easy_install
# NOTICE: this loop can only be extented if the egg name is the same in both the python code and module name in bash!
for egg in pip six tkinter pyttk matplotlib; do
    sudo easy_install3 $egg
done


pip freeze

cd -

# 4.
sudo rm -rf $matlib

No comments: