forked from dpinney/omf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.py
102 lines (100 loc) · 5.75 KB
/
install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import platform, os, sys
def pipInstallInOrder(pipCommandString):
with open("requirements.txt","r") as f:
for line in f:
os.system(pipCommandString + " install " + line)
# Removes pip log files.
os.system("rm \\=*")
# Note: all installations require git to clone the omf first.
if platform.system() == "Linux" and platform.linux_distribution()[0] in ["Ubuntu","debian"]:
os.system("sudo apt-get -y update") # Make sure apt-get is updated to prevent any weird package installation issues
os.system("sudo apt-get -y install language-pack-en") # Install English locale
os.system("sudo apt-get -y install python-pip git unixodbc-dev libfreetype6-dev \
pkg-config python-dev python-numpy alien graphviz python-pygraphviz libgraphviz-dev \
python-pydot mdbtools python-tk octave libblas-dev liblapack-dev libatlas-base-dev gfortran wget splat")
try:
os.system("sudo apt-get -y install ffmpeg python-cairocffi")
except:
pass # Debian won't bundle a couple packages.
os.system("wget https://sourceforge.net/projects/gridlab-d/files/gridlab-d/Candidate%20release/gridlabd-4.0.0-1.el6.x86_64.rpm")
os.system("sudo alien -i gridlabd-4.0.0-1.el6.x86_64.rpm")
os.system("sudo apt-get install -f")
os.system("cd omf")
os.system("pip install --upgrade pip")
pipInstallInOrder("pip")
os.system("python setup.py develop")
elif platform.system() == "Linux" and platform.linux_distribution()[0]=="CentOS Linux":
# CentOS Docker image appears to come with en_US.UTF-8 locale built-in, but we might need to install that locale in the future. That currently is
# not done here.
os.system("yum -y update") # Make sure yum is updated to prevent any weird package installation issues
os.system("sudo yum -y install wget git graphviz gcc xerces-c python-devel tkinter octave 'graphviz-devel.x86_64'")
os.system("yum --enablerepo=extras install epel-release")
os.system("sudo yum -y install mdbtools")
os.system("sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro")
os.system("sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm")
os.system("sudo yum -y install ffmpeg ffmpeg-devel -y")
os.system("sudo yum -y install python-pip")
os.system("wget --no-check-certificate https://sourceforge.net/projects/gridlab-d/files/gridlab-d/Candidate%20release/gridlabd-4.0.0-1.el6.x86_64.rpm")
os.system("rpm -Uvh gridlabd-4.0.0-1.el6.x86_64.rpm")
os.system("cd omf")
pipInstallInOrder("pip")
os.system("pip install --ignore-installed six")
os.system("python setup.py develop")
elif platform.system()=='Windows':
# Choco install.
# chocoString = @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
# os.system(chocoString)
# Check for right Python version.
version = sys.version.split('\n')[0]
if not version.startswith('2.'):
os.system("choco install -y python2")
# Install choco packages.
os.system("choco install -y wget")
os.system("choco install -y vcredist2008")
os.system("choco install -y ffmpeg")
os.system("choco install -y graphviz")
os.system("choco install -y pip")
os.system("choco install -y octave.portable")
#TODO: find way to install mdbtools.
# HACK: timeout and refreshenv should get all the choco binaries on to the path.
os.system("timeout 5")
os.system("refreshenv")
# Install GridLAB-D.
os.system("wget --no-check-certificate https://sourceforge.net/projects/gridlab-d/files/gridlab-d/Candidate%20release/gridlabd-4.0_RC1.exe")
os.system("gridlabd-4.0_RC1.exe/silent")
#Install splat
#os.system(wget https://www.qsl.net/kd2bd/Splat-1.3.0.zip)
#os.system(Splat-1.3.0/Splat-1-3-1-SD-mx64.exe)
# Install pygraphviz.
if platform.architecture()[0] == '32bit':
os.system("C:\\Python27\\python.exe -m pip install omf\\static\\pygraphviz-1.3.1-cp27-none-win32.whl")
elif platform.architecture()[0] == '64bit':
os.system("C:\\Python27\\python.exe -m pip install omf\\static\\pygraphviz-1.3.1-cp27-none-win_amd64.whl")
# Finish up installation with pip.
os.system("cd omf")
# HACK: more refreshes of the environment.
os.system("timeout 5")
os.system("refreshenv")
os.system("C:\\Python27\\python.exe -m pip install scipy")
os.system("C:\\Python27\\python.exe -m pip install setuptools>=33.1.1")
pipInstallInOrder("C:\\Python27\\python.exe -m pip")
os.system("C:\\Python27\\python.exe -m setup.py develop")
elif platform.system()=="Darwin": # MacOS
# Might need to install en_US.UTF-8 locale, like for Ubuntu? That currently is not done in this script. macOS might already come with this locale anyway.
# Install homebrew
os.system('/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"')
os.system("brew install wget python@2 ffmpeg git graphviz octave mdbtools")
os.system("brew link --overwrite python")
os.system("wget -O gridlabd.dmg --no-check-certificate https://sourceforge.net/projects/gridlab-d/files/gridlab-d/Candidate%20release/gridlabd_4.0.0.dmg")
os.system("sudo hdiutil attach gridlabd.dmg")
os.system('sudo installer -package "/Volumes/GridLAB-D 4.0.0/gridlabd.mpkg" -target /')
os.system('sudo hdiutil detach "/Volumes/GridLAB-D 4.0.0"')
#splat install
#os.system("wget https://www.qsl.net/kd2bd/splat-1.4.2-osx.tgz")
#os.system("sudo tar -xvzf splat-1.4.2-osx.tgz")
#os.system("sudo exec splat-1.4.2/configure")
os.system("cd omf")
pipInstallInOrder("pip2")
os.system("python2 setup.py develop")
else:
print "Your operating system is not currently supported. Platform detected: " + str(platform.system()) + str(platform.linux_distribution())