Skip to content

Commit a2f1b97

Browse files
Merge pull request #138 from OpenSourceBrain/feat-use-jnml-from-pyneuroml
Feat: use jnml from pyneuroml
2 parents f13cfbb + 55a859a commit a2f1b97

File tree

4 files changed

+18
-47
lines changed

4 files changed

+18
-47
lines changed

omv/common/inout.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import yaml
2-
from collections import deque
31
import os
4-
import sys
52

63
# import textwrap
74
import subprocess as sp
5+
from collections import deque
6+
7+
import yaml
88

99
LINEWIDTH = 70
1010
__PROMPT__ = "[omv] "
@@ -25,10 +25,7 @@ def omvify(x):
2525

2626

2727
def check(b):
28-
if sys.version_info >= (3, 0):
29-
tick = "\u2714" if b else "\u2718"
30-
else:
31-
tick = "\u2714" if b else "\u2718"
28+
tick = "\u2714" if b else "\u2718"
3229
return tick
3330

3431

@@ -57,11 +54,7 @@ def inform(
5754
else:
5855
p = pars if pars else ""
5956
# print("msg is %s"%msg.__class__)
60-
msgstr = (
61-
msg.encode("utf-8")
62-
if sys.version_info[0] == 2 and isinstance(msg, unicode)
63-
else str(msg)
64-
)
57+
msgstr = str(msg)
6558
infostr = msgstr + str(p)
6659
block = deque([infostr])
6760

@@ -128,7 +121,7 @@ def check_output(cmds, cwd=".", shell=False, verbosity=0, env=None):
128121

129122

130123
def pip_install(packages, version=None):
131-
pip = "pip3" if sys.version_info.major == 3 else "pip"
124+
pip = "pip"
132125
cmds = [pip, "install"]
133126
if isinstance(packages, str):
134127
if version is None:

omv/engines/getjnml.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99

1010
def install_jnml(version):
11+
"""Install JNeuroML from GitHub tar."""
1112
if not version:
1213
version = "v0.14.0"
1314

omv/engines/jneuroml.py

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,23 @@
22
import shutil
33
import subprocess as sp
44
from pathlib import Path
5-
import platform
65

7-
from omv.common.inout import inform, trim_path, is_verbose, check_output
8-
from omv.engines.engine import OMVEngine, EngineExecutionError
6+
from omv.common.inout import check_output, inform, is_verbose, trim_path
7+
from omv.engines.engine import EngineExecutionError, OMVEngine
98

109

1110
class JNeuroMLEngine(OMVEngine):
1211
name = "jNeuroML"
12+
e_name = "jnml"
1313

1414
@staticmethod
1515
def get_environment():
1616
if "JNML_HOME" in os.environ:
1717
jnmlhome = os.environ["JNML_HOME"]
18-
elif shutil.which("jnml") is not None:
19-
jnmlhome = Path(shutil.which("jnml")).parent
18+
elif shutil.which(JNeuroMLEngine.e_name) is not None:
19+
jnmlhome = Path(shutil.which(JNeuroMLEngine.e_name)).parent
2020
else:
21-
osname = platform.system()
22-
if osname == "Linux":
23-
try:
24-
jnmlhome = os.path.join(
25-
os.environ["XDG_DATA_HOME"], "jnml/jNeuroMLJar"
26-
)
27-
except KeyError:
28-
localsharepath = os.path.join(os.environ["HOME"], ".local/share")
29-
if os.path.isdir(localsharepath):
30-
jnmlhome = os.path.join(
31-
os.environ["HOME"], ".local/share/jnml/jNeuroMLJar"
32-
)
33-
else:
34-
jnmlhome = os.path.join(os.environ["HOME"], "jnml/jNeuroMLJar")
35-
36-
elif osname == "Darwin":
37-
jnmlhome = os.path.join(os.environ["HOME"], "Library/jnml/jNeuroMLJar")
38-
else:
39-
jnmlhome = os.path.join(os.environ["HOME"], "jnml/jNeuroMLJar")
21+
jnmlhome = ""
4022

4123
environment_vars = {"JNML_HOME": jnmlhome}
4224

@@ -45,9 +27,7 @@ def get_environment():
4527
@staticmethod
4628
def get_executable():
4729
environment_vars = JNeuroMLEngine.get_environment()
48-
jnml = os.path.join(
49-
environment_vars["JNML_HOME"], "jnml" if os.name != "nt" else "jnml.bat"
50-
)
30+
jnml = os.path.join(environment_vars["JNML_HOME"], JNeuroMLEngine.e_name)
5131
return jnml
5232

5333
@staticmethod
@@ -59,7 +39,6 @@ def is_installed():
5939
"Checking whether %s is installed..." % JNeuroMLEngine.name,
6040
indent=1,
6141
)
62-
FNULL = open(os.devnull, "w")
6342
jnml = JNeuroMLEngine.get_executable()
6443
r = check_output(
6544
[jnml, "-v"], verbosity=2, env=JNeuroMLEngine.get_environment()
@@ -76,10 +55,10 @@ def is_installed():
7655

7756
@staticmethod
7857
def install(version):
79-
from omv.engines.getjnml import install_jnml
58+
from omv.engines.getpyneuroml import install_pynml
8059

81-
inform("Will fetch and install jNeuroML jar", indent=2)
82-
install_jnml(version)
60+
inform("Will install PyNeuroML for jnml", indent=2)
61+
install_pynml(version)
8362

8463
if not JNeuroMLEngine.is_installed():
8564
inform("Failure to install, exiting", indent=1)

omv/omv_util.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,7 @@ def _install_engine(eng):
228228
if ee.is_installed():
229229
already_installed = True
230230
else:
231-
from omv.engines.getjnml import install_jnml
232-
233-
install_jnml(engine_version)
231+
ee.install(None)
234232

235233
elif eng.lower() == "neuroConstruct" or eng == "Py_neuroConstruct".lower():
236234
from omv.engines.pyneuroconstruct import PyneuroConstructEngine as ee

0 commit comments

Comments
 (0)