Skip to content

Commit 681c91f

Browse files
committed
Pull request #258: Bugfix/github issue 10
Merge in LCL/wolframclientforpython from bugfix/github-issue-10 to master * commit '8244d8c51a13f9578b60d50a978cb8a0c58c7f7d': bump version add comment code lint fixing initfile
2 parents 51939b8 + 8244d8c commit 681c91f

File tree

9 files changed

+31
-23
lines changed

9 files changed

+31
-23
lines changed

wolframclient/about.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
__name__ = "wolframclient"
44
__description__ = "A Python library with various tools to interact with the Wolfram Language and the Wolfram Cloud."
5-
__version__ = "1.1.9"
5+
__version__ = "1.1.10"
66
__author__ = "Wolfram Research"
77

wolframclient/cli/commands/refactor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ class Command(SimpleCommand):
1010

1111
modules = ["wolframclient"]
1212

13-
dependencies = (("isort", "5.3.2"), ("autoflake", "1.3"), ("black", "19.3b0"))
13+
#dependencies = (("isort", "5.3.2"), ("autoflake", "1.3"), ("black", "19.3b0"))
14+
#dependencies is broken please install isort==5.3.2 autoflake==1.3 black==19.3b0"
1415

1516
def _module_args(self, *args):
1617

wolframclient/cli/commands/start_externalevaluate.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ def add_arguments(self, parser):
1919

2020
def handle(self, port=None, installpath=None, kernelversion=None, **opts):
2121

22-
for key, value in (("WOLFRAM_INSTALLATION_DIRECTORY", installpath), ("WOLFRAM_KERNEL_VERSION", kernelversion)):
22+
for key, value in (
23+
("WOLFRAM_INSTALLATION_DIRECTORY", installpath),
24+
("WOLFRAM_KERNEL_VERSION", kernelversion),
25+
):
2326
if value:
2427
os.environ[key] = value
2528

wolframclient/evaluation/kernel/kernelcontroller.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from subprocess import PIPE, Popen
88
from threading import Event, RLock, Thread
99

10-
from wolframclient.utils.environment import find_default_kernel_path
1110
from wolframclient.evaluation.kernel.zmqsocket import (
1211
Socket,
1312
SocketAborted,
@@ -17,6 +16,8 @@
1716
from wolframclient.exception import WolframKernelException
1817
from wolframclient.utils import six
1918
from wolframclient.utils.api import json, os, time, zmq
19+
from wolframclient.utils.environment import find_default_kernel_path
20+
from wolframclient.utils.functional import iterate
2021

2122
if six.WINDOWS:
2223
from subprocess import STARTF_USESHOWWINDOW, STARTUPINFO
@@ -130,12 +131,13 @@ def __init__(
130131
"Cannot locate a kernel automatically. Please provide an explicit kernel path."
131132
)
132133

133-
if initfile is None:
134-
self.initfile = os.path_join(os.dirname(__file__), "initkernel.m")
135-
else:
136-
self.initfile = initfile
137-
if not os.isfile(self.initfile):
138-
raise FileNotFoundError("Kernel initialization file %s not found." % self.initfile)
134+
self.initfile = tuple(
135+
iterate(initfile or (), os.path_join(os.dirname(__file__), "initkernel.m"))
136+
)
137+
for path in self.initfile:
138+
if not os.isfile(path):
139+
raise FileNotFoundError("Kernel initialization file %s not found." % path)
140+
139141
if logger.isEnabledFor(logging.DEBUG):
140142
logger.debug(
141143
"Initializing kernel %s using script: %s" % (self.kernel, self.initfile)
@@ -384,7 +386,12 @@ def _kernel_start(self):
384386
"Kernel receives evaluated expressions from socket: %s", self.kernel_socket_in
385387
)
386388
# start the kernel process
387-
cmd = [self.kernel, "-noprompt", "-initfile", self.initfile]
389+
cmd = [self.kernel, "-noprompt"]
390+
391+
for path in self.initfile:
392+
cmd.append("-initfile")
393+
cmd.append(path)
394+
388395
if self.loglevel != logging.NOTSET:
389396
self.kernel_logger = KernelLogger(
390397
name="wolfram-kernel-logger-%i" % self.id, level=self.loglevel

wolframclient/serializers/base.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
from wolframclient.utils.encoding import concatenate_bytes, force_text
1616
from wolframclient.utils.functional import first
1717

18-
if hasattr(inspect, 'getfullargspec'):
18+
if hasattr(inspect, "getfullargspec"):
1919
inspect_args = inspect.getfullargspec
20-
elif hasattr(inspect, 'getargspec'):
20+
elif hasattr(inspect, "getargspec"):
2121
inspect_args = inspect.getargspec
2222
else:
23+
2324
def inspect_args(f):
2425
raise TypeError()
2526

wolframclient/serializers/encoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
from collections import defaultdict
66
from functools import partial
77

8-
from wolframclient.utils.environment import installation_version
98
from wolframclient.serializers.utils import safe_len
109
from wolframclient.utils.api import multiprocessing, pkg_resources
1110
from wolframclient.utils.dispatch import Dispatch
11+
from wolframclient.utils.environment import installation_version
1212
from wolframclient.utils.functional import composition, is_iterable, iterate, map
1313
from wolframclient.utils.importutils import safe_import_string
1414

wolframclient/tests/externalevaluate/ev_loop.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from threading import Thread
44

55
import zmq
6-
76
from wolframclient.language import wl
87
from wolframclient.serializers import export
98
from wolframclient.utils.externalevaluate import EXPORT_KWARGS, start_zmq_loop

wolframclient/tests/serializers/wxf_numpy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def test_scalars(self):
228228
for arr, result in (
229229
(numpy.array(1, dtype=numpy.int8), b"1"),
230230
(numpy.array(0.5, dtype=numpy.float32), b"0.5"),
231-
):
231+
):
232232
self.assertEqual(export(arr), result)
233233

234234
def test_bad_options(self):

wolframclient/utils/environment.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
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
86

97
def installation_version():
108

11-
v = os.environ.get('WOLFRAM_KERNEL_VERSION', None)
9+
v = os.environ.get("WOLFRAM_KERNEL_VERSION", None)
1210
if v:
1311
return float(v)
1412

1513
return 12.0
1614

15+
1716
def _explore_paths(*paths):
1817
highest_version = -1
1918
best_path = None
@@ -60,17 +59,15 @@ def _installation_directories():
6059
yield "/Applications/Wolfram Engine.app/Contents"
6160

6261

63-
6462
def find_default_kernel_path():
6563
""" Look for the most recent installed kernel. """
6664

6765
if six.WINDOWS:
6866
rel = "WolframKernel.exe"
6967
elif six.LINUX:
70-
rel = "Executables/WolframKernel"
68+
rel = "Executables/WolframKernel"
7169
elif six.MACOS:
72-
rel = "MacOS/WolframKernel"
73-
70+
rel = "MacOS/WolframKernel"
7471

7572
for path in _installation_directories():
7673
if rel:

0 commit comments

Comments
 (0)