|
2 | 2 | from setuptools.command.install import install |
3 | 3 | import subprocess |
4 | 4 | import json |
5 | | -import os |
| 5 | +import os, sys |
6 | 6 | from shutil import copyfile |
7 | 7 |
|
8 | | -# Cloning Repos |
9 | | -print("Cloning PyGeppetto...") |
10 | | -subprocess.call(['git', 'clone', '-b', 'v0.4.1-M1', 'https://github.com/openworm/pygeppetto.git'], cwd='../') |
11 | | -subprocess.call(['pip', 'install', '-e', '.'], cwd='../pygeppetto/') |
| 8 | +branch = "development" |
| 9 | + |
| 10 | +#by default clones branch (which can be passed as a parameter python install.py branch test_branch) |
| 11 | +#if branch doesnt exist clones the default_branch |
| 12 | +def clone(repository, folder, default_branch, cwdp='', recursive = False): |
| 13 | + global branch |
| 14 | + print("Cloning "+repository) |
| 15 | + if recursive: |
| 16 | + subprocess.call(['git', 'clone', '--recursive', repository], cwd='./'+cwdp) |
| 17 | + else: |
| 18 | + subprocess.call(['git', 'clone', repository], cwd='./'+cwdp) |
| 19 | + checkout(folder, default_branch, cwdp) |
12 | 20 |
|
13 | | -print("Cloning NetPyNE...") |
14 | | -subprocess.call(['git', 'clone', '-b', 'v0.7.8_UI0.3Release', 'https://github.com/Neurosim-lab/netpyne.git'], cwd='../') |
15 | | -subprocess.call(['pip', 'install', '-e', '.'], cwd='../netpyne/') |
| 21 | +def checkout(folder, default_branch, cwdp): |
| 22 | + currentPath = os.getcwd() |
| 23 | + print currentPath |
| 24 | + newPath = currentPath+"/"+cwdp+folder |
| 25 | + print newPath |
| 26 | + os.chdir(newPath) |
| 27 | + python_git=subprocess.Popen("git branch -a",shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE) |
| 28 | + outstd,errstd=python_git.communicate() |
| 29 | + if branch in outstd: |
| 30 | + subprocess.call(['git', 'checkout', branch], cwd='./') |
| 31 | + else: |
| 32 | + subprocess.call(['git', 'checkout', default_branch], cwd='./') |
| 33 | + os.chdir(currentPath) |
16 | 34 |
|
17 | | -print("Cloning Geppetto Jupyter (Python package)...") |
18 | | -subprocess.call(['git', 'clone', '--recursive', '-b', 'v0.4.1-M1', 'https://github.com/openworm/org.geppetto.frontend.jupyter.git'], cwd='../') |
| 35 | +def main(argv): |
| 36 | + global branch |
| 37 | + if(len(argv) > 0): |
| 38 | + if(argv[0] == 'branch'): |
| 39 | + branch = argv[1] |
19 | 40 |
|
20 | | -print("Cloning Geppetto Frontend") |
21 | | -subprocess.call(['git', 'checkout', 'v0.4.1-M1'], cwd='../org.geppetto.frontend.jupyter/src/jupyter_geppetto/geppetto/') |
| 41 | +if __name__ == "__main__": |
| 42 | + main(sys.argv[1:]) |
22 | 43 |
|
23 | | -print("Cloning Geppetto NetPyNE Configuration ...") |
24 | | -subprocess.call(['git', 'clone', 'https://github.com/MetaCell/geppetto-netpyne.git'], |
25 | | - cwd='../org.geppetto.frontend.jupyter/src/jupyter_geppetto/geppetto/src/main/webapp/extensions/') |
| 44 | +os.chdir(os.getcwd()+"/../") |
| 45 | +# Cloning Repos |
| 46 | +clone('https://github.com/openworm/pygeppetto.git','pygeppetto','v0.4.1-M1') |
| 47 | +subprocess.call(['pip', 'install', '-e', '.'], cwd='./pygeppetto/') |
26 | 48 |
|
27 | | -subprocess.call(['git', 'checkout', '0.3'], cwd='../org.geppetto.frontend.jupyter/src/jupyter_geppetto/geppetto/src/main/webapp/extensions/geppetto-netpyne/') |
| 49 | +clone('https://github.com/Neurosim-lab/netpyne.git','netpyne','metadata') |
| 50 | +subprocess.call(['pip', 'install', '-e', '.'], cwd='./netpyne/') |
| 51 | + |
| 52 | +clone('https://github.com/openworm/org.geppetto.frontend.jupyter.git','org.geppetto.frontend.jupyter','v0.4.1-M1','', True ) |
| 53 | +checkout('geppetto', 'v0.4.1-M1','org.geppetto.frontend.jupyter/src/jupyter_geppetto/') |
| 54 | +clone('https://github.com/MetaCell/geppetto-netpyne.git','geppetto-netpyne','0.3','org.geppetto.frontend.jupyter/src/jupyter_geppetto/geppetto/src/main/webapp/extensions/') |
28 | 55 |
|
29 | 56 | print("Enabling Geppetto NetPyNE Extension ...") |
30 | | -geppetto_configuration = os.path.join(os.path.dirname(__file__), 'GeppettoConfiguration.json') |
31 | | -copyfile(geppetto_configuration, '../org.geppetto.frontend.jupyter/src/jupyter_geppetto/geppetto/src/main/webapp/GeppettoConfiguration.json') |
| 57 | +geppetto_configuration = os.path.join(os.path.dirname(__file__), './utilities/GeppettoConfiguration.json') |
| 58 | +copyfile(geppetto_configuration, './org.geppetto.frontend.jupyter/src/jupyter_geppetto/geppetto/src/main/webapp/GeppettoConfiguration.json') |
32 | 59 |
|
33 | 60 | # Installing and building |
34 | 61 | print("NPM Install and build for Geppetto Frontend ...") |
35 | | -subprocess.call(['npm', 'install'], cwd='../org.geppetto.frontend.jupyter/src/jupyter_geppetto/geppetto/src/main/webapp/') |
36 | | -subprocess.call(['npm', 'run', 'build-dev-noTest'], cwd='../org.geppetto.frontend.jupyter/src/jupyter_geppetto/geppetto/src/main/webapp/') |
| 62 | +subprocess.call(['npm', 'install'], cwd='./org.geppetto.frontend.jupyter/src/jupyter_geppetto/geppetto/src/main/webapp/') |
| 63 | +subprocess.call(['npm', 'run', 'build-dev-noTest'], cwd='./org.geppetto.frontend.jupyter/src/jupyter_geppetto/geppetto/src/main/webapp/') |
37 | 64 |
|
38 | 65 | print("Installing jupyter_geppetto python package ...") |
39 | | -subprocess.call(['pip', 'install', '-e', '.'], cwd='../org.geppetto.frontend.jupyter') |
| 66 | +subprocess.call(['pip', 'install', '-e', '.'], cwd='./org.geppetto.frontend.jupyter') |
40 | 67 | print("Installing jupyter_geppetto Jupyter Extension ...") |
41 | | -subprocess.call(['jupyter', 'nbextension', 'install', '--py', '--symlink', '--user', 'jupyter_geppetto'], cwd='../org.geppetto.frontend.jupyter') |
42 | | -subprocess.call(['jupyter', 'nbextension', 'enable', '--py', '--user', 'jupyter_geppetto'], cwd='../org.geppetto.frontend.jupyter') |
43 | | -subprocess.call(['jupyter', 'nbextension', 'enable', '--py', 'widgetsnbextension'], cwd='../org.geppetto.frontend.jupyter') |
44 | | -subprocess.call(['jupyter', 'serverextension', 'enable', '--py', 'jupyter_geppetto'], cwd='../org.geppetto.frontend.jupyter') |
| 68 | +subprocess.call(['jupyter', 'nbextension', 'install', '--py', '--symlink', '--user', 'jupyter_geppetto'], cwd='./org.geppetto.frontend.jupyter') |
| 69 | +subprocess.call(['jupyter', 'nbextension', 'enable', '--py', '--user', 'jupyter_geppetto'], cwd='./org.geppetto.frontend.jupyter') |
| 70 | +subprocess.call(['jupyter', 'nbextension', 'enable', '--py', 'widgetsnbextension'], cwd='./org.geppetto.frontend.jupyter') |
| 71 | +subprocess.call(['jupyter', 'serverextension', 'enable', '--py', 'jupyter_geppetto'], cwd='./org.geppetto.frontend.jupyter') |
45 | 72 |
|
46 | 73 | print("Installing NetPyNE UI python package ...") |
47 | | -subprocess.call(['pip', 'install', '-e', '.'], cwd='..') |
48 | | - |
| 74 | +subprocess.call(['pip', 'install', '-e', '.'], cwd='.') |
0 commit comments