Skip to content

Commit 982abdc

Browse files
committed
adding installation_version, refactoring internals
1 parent 15fcdd9 commit 982abdc

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

wolframclient/utils/environment.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,18 @@
33
from wolframclient.utils import six
44
from wolframclient.utils.api import os
55

6+
from wolframclient.utils import six
7+
from wolframclient.utils.api import os
8+
9+
def installation_version():
610

7-
def explore_paths(*paths):
11+
v = os.environ.get('WOLFRAM_KERNEL_VERSION', None)
12+
if v:
13+
return float(v)
14+
15+
return 12.0
16+
17+
def _explore_paths(*paths):
818
highest_version = -1
919
best_path = None
1020
for root in paths:
@@ -23,21 +33,21 @@ def explore_paths(*paths):
2333
yield best_path
2434

2535

26-
def installation_directories():
36+
def _installation_directories():
2737
env = os.environ.get("WOLFRAM_INSTALLATION_DIRECTORY", None)
2838
if env:
2939
yield env
3040

3141
if six.WINDOWS:
32-
for p in explore_paths(
42+
for p in _explore_paths(
3343
"C:\\Program Files\\Wolfram Research\\Wolfram Desktop",
3444
"C:\\Program Files\\Wolfram Research\\Mathematica",
3545
"C:\\Program Files\\Wolfram Research\\Wolfram Engine",
3646
):
3747
yield p
3848

3949
elif six.LINUX:
40-
for p in explore_paths(
50+
for p in _explore_paths(
4151
"/usr/local/Wolfram/Desktop",
4252
"/usr/local/Wolfram/Mathematica",
4353
"/usr/local/Wolfram/WolframEngine",
@@ -50,19 +60,19 @@ def installation_directories():
5060
yield "/Applications/Wolfram Engine.app/Contents"
5161

5262

53-
def exe_path():
63+
64+
def find_default_kernel_path():
65+
""" Look for the most recent installed kernel. """
66+
5467
if six.WINDOWS:
55-
return "WolframKernel.exe"
68+
rel = "WolframKernel.exe"
5669
elif six.LINUX:
57-
return "Executables/WolframKernel"
70+
rel = "Executables/WolframKernel"
5871
elif six.MACOS:
59-
return "MacOS/WolframKernel"
72+
rel = "MacOS/WolframKernel"
73+
6074

61-
62-
def find_default_kernel_path():
63-
""" Look for the most recent installed kernel. """
64-
rel = exe_path()
65-
for path in installation_directories():
75+
for path in _installation_directories():
6676
if rel:
6777
path = os.path_join(path, rel)
6878
if os.isfile(path):

0 commit comments

Comments
 (0)