jpcad/install-deps
2011-10-03 21:16:32 -04:00

57 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python
import os
import sys
import re
from subprocess import Popen, PIPE
DEPS_DIR = 'deps'
NUMPY_VER = '1.6.1'
numpy_src = 'numpy-%s.tar.gz' % NUMPY_VER
numpy_url = 'http://downloads.sourceforge.net/project/numpy/NumPy/%s/numpy-%s.tar.gz' % (NUMPY_VER, NUMPY_VER)
funcdesigner_src = 'FuncDesigner.zip'
funcdesigner_url = 'http://trac.openopt.org/openopt/changeset/latest/PythonPackages/FuncDesigner?old_path=%2F&format=zip'
def indirdo(dr, fn):
owd = os.getcwd()
os.chdir(dr)
fn()
os.chdir(owd)
def get_file(url, fname):
Popen(['wget', '-O', fname, url]).wait()
if not os.path.exists(DEPS_DIR):
os.makedirs(DEPS_DIR)
os.chdir(DEPS_DIR)
if not os.path.exists(numpy_src):
get_file(numpy_url, numpy_src)
if not os.path.exists(funcdesigner_src):
get_file(funcdesigner_url, funcdesigner_src)
if not os.path.exists(numpy_src.replace('.tar.gz', '')):
Popen(['tar', '-xvzf', numpy_src]).wait()
if not os.path.exists('PythonPackages/FuncDesigner'):
Popen(['unzip', funcdesigner_src]).wait()
try:
exec 'import numpy'
except:
indirdo('numpy-%s' % NUMPY_VER, lambda:
Popen(['sudo', 'python', 'setup.py', 'install']).wait())
try:
exec 'import FuncDesigner'
except:
indirdo('PythonPackages/FuncDesigner', lambda:
Popen(['sudo', 'python', 'setup.py', 'install']).wait())
try:
exec 'import gtkgl'
except:
Popen(['sudo', 'apt-get', 'install', 'python-gtkglext1']).wait()