forked from dpinney/omf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.py
105 lines (103 loc) · 5.91 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
103
104
105
import platform, os, sys
def pipInstallInOrder(pipCommandString):
''' This shouldn't be required, but pip doesn't resolve dependencies correctly unless we do this.'''
with open("requirements.txt","r") as f:
for line in f:
if not line.startswith('#'):
os.system(pipCommandString + " install " + line)
# Removes pip log files.
os.system("rm \\=*")
if platform.system() == "Linux" and platform.linux_distribution()[0] in ["Ubuntu","debian"]:
os.system("sudo apt-get -y update && sudo apt-get -y upgrade") # 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 DEBIAN_FRONTEND=noninteractive apt-get -y install git python3-pip python3-dev python3-numpy python3-pygraphviz graphviz \
unixodbc-dev libfreetype6-dev pkg-config alien libgraphviz-dev python3-pydot mdbtools python3-tk octave libblas-dev liblapack-dev \
libatlas-base-dev gfortran wget splat")
try:
os.system("sudo apt-get -y install ffmpeg python3-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("pip3 install --upgrade pip")
pipInstallInOrder("pip3")
os.system("python3 setup.py develop")
# TODO: Double check CentOS installation to support Python 3.7 or up
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("pip3")
os.system("pip3 install --ignore-installed six")
os.system("python3 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.
pybin = os.popen('where python').read()
goodbin = 'C:\\Python36\\python.exe'
if pybin != goodbin:
print('Non-standard python install detected. We will attempt to continue with choco.')
os.system("choco install -y python --version 3.6.8")
# Hack to create a python3 binary on the path.
os.system("copy C:\\Python36\\python.exe C:\\Python36\\python3.exe")
# Update pip to remove warnings
os.system("python3 -m pip install --upgrade pip")
# Install choco packages.
os.system("choco install -y wget")
os.system("choco install -y vcredist-all")
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.
# 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")
# os.system("refreshenv")
#Install splat
#os.system(wget http://www.ve3ncq.ca/software/SPLAT-1.3.1.zip)
#os.system(unzip SPLAT-1.3.1.zip) #need to rename/copy these files.
# Install pygraphviz from wheel because it's finicky
graphVizBinPath = "C:\\Program Files (x86)\\Graphviz2.38\\bin"
os.system(f'setx path "%path%;{graphVizBinPath}"')
os.system(f"set PATH=%PATH%;{graphVizBinPath}")
os.system("python3.exe -m pip install omf\\static\\pygraphviz-1.5-cp36-cp36m-win_amd64.whl")
# Finish up installation with pip.
pipInstallInOrder("python3 -m pip")
os.system("python3 setup.py develop")
elif platform.system()=="Darwin": # MacOS
# Install homebrew
os.system("HOMEBREW_NO_AUTO_UPDATE=1 brew install wget ffmpeg git graphviz octave mdbtools") # Set no-update to keep homebrew from blowing away python3.
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('''
cd splat-1.4.2;
sed -i '' 's/ans=""/ans="2"/g' configure;
sudo bash configure;
''') # sed is to hack the build to work without user input.
# pip installs
os.system("cd omf")
os.system('pip3 install pygraphviz --install-option="--include-path=/usr/local/include/graphviz" --install-option="--library-path=/usr/local/lib/graphviz/"')
os.system('pip3 install "ecos >= 2.0.7rc2"')
pipInstallInOrder("pip3")
os.system("python3 setup.py develop")
else:
print("Your operating system is not currently supported. Platform detected: " + str(platform.system()) + str(platform.linux_distribution()))