-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_dependencies.py
53 lines (47 loc) · 2.31 KB
/
update_dependencies.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
import os
import zipfile
import shutil
import subprocess
from urllib.request import urlretrieve
def pull_light_wrapper():
# Checks if the light_python_wrapper submodule has been fetched. If not, get it from github
if not os.path.isfile('light_python_wrapper/+light_python_wrapper/light_python_wrapper.m'):
zip_name = 'master.zip'
gh_zip = 'https://github.com/pace-neutrons/light_python_wrapper/archive/' + zip_name
urlretrieve(gh_zip, zip_name)
zf = zipfile.ZipFile(zip_name)
zf.extractall('.')
rtfolder = zf.infolist()[0].filename
shutil.copytree(rtfolder+'/+light_python_wrapper', 'light_python_wrapper/+light_python_wrapper')
def pull_euphonic_sqw_models():
# Checks if the euphonic_sqw_models submodule has been fetched. If not, get it from github
if not os.path.isfile('euphonic_sqw_models/euphonic_sqw_models/euphonic_wrapper.py'):
zip_name = 'main.zip'
gh_zip = 'https://github.com/pace-neutrons/euphonic_sqw_models/archive/' + zip_name
urlretrieve(gh_zip, zip_name)
zf = zipfile.ZipFile(zip_name)
zf.extractall('.')
rtfolder = zf.infolist()[0].filename
shutil.copytree(rtfolder+'/euphonic_sqw_models', 'euphonic_sqw_models/euphonic_sqw_models')
shutil.copyfile(rtfolder+'/min_requirements.txt', 'euphonic_sqw_models/min_requirements.txt')
def update_submodules(submodule=None):
curdir = os.path.dirname(os.path.abspath(__file__))
submodules = {
'euphonic_sqw_models':
{'required_path': os.path.join(
curdir,
os.path.join('euphonic_sqw_models', 'euphonic_sqw_models', 'euphonic_wrapper.py'))},
'light_python_wrapper':
{'required_path': os.path.join(
curdir,
os.path.join('light_python_wrapper', '+light_python_wrapper', 'light_python_wrapper.m'))}}
if submodule is not None:
submodules = {submodule: submodules[submodule]}
for key, val in submodules.items():
if not os.path.isfile(val['required_path']):
cmd = 'git submodule update --init ' + key
print(cmd)
ret = subprocess.run(cmd)
ret.check_returncode()
else:
print(f"{val['required_path']} already present, not updating {key}")