Skip to content

Commit 4bf74b9

Browse files
author
Raj Balaebail
committed
Merge pull request #232 in LCL/wolframclientforpython from bugfix/380061-removing-dependencies to release/B12_1_0
* commit 'd4b93dbacb7cdc9c59884115a0d9e7a63f5e25a2': (21 commits) this should be called multiprocessing removing unused code automatic code refactor Update lock.py when pkg_resources are not available we can return a tuple using dynamic import fixing external libraries using asyncio api fixing indent using dynamic import when calling cProfile add test to ensure sslcontext is initialized correctly Warning should be displayed once and for all multithreading module does not exist remove useless pass increment version Update changelog aiohttp based classes now use certifi update ssl api removing unused vars for clarity Add test with big real and neg exponent. ...
2 parents 37c45ea + d4b93db commit 4bf74b9

11 files changed

Lines changed: 24 additions & 20 deletions

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
def read(*rellibpath):
3434
with codecs.open(os.path.join(HERE, *rellibpath), 'r', encoding='utf-8') as fp:
35-
return fp.read()
35+
return fp.read()
3636

3737
def load_tests():
3838
import unittest

wolframclient/cli/commands/benchmark.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import absolute_import, print_function, unicode_literals
22

3-
import cProfile
43
import decimal
54
import os
65
import tempfile
@@ -12,6 +11,7 @@
1211
from wolframclient.utils.debug import timed
1312
from wolframclient.utils.encoding import force_text
1413
from wolframclient.utils.functional import first
14+
from wolframclient.utils.importutils import safe_import_string_and_call
1515

1616

1717
def repeat(el, n=1):
@@ -125,6 +125,8 @@ def report(self):
125125

126126
def handle(self, profile, **opts):
127127
if profile:
128-
cProfile.runctx("report()", {"report": self.report}, {})
128+
safe_import_string_and_call(
129+
"cProfile.runctx", "report()", {"report": self.report}, {}
130+
)
129131
else:
130132
self.report()

wolframclient/evaluation/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from __future__ import absolute_import, print_function, unicode_literals
22

3-
import asyncio
43
import warnings
54

65
from wolframclient.language import wlexpr
76
from wolframclient.language.expression import WLFunction
87
from wolframclient.utils import six
8+
from wolframclient.utils.api import asyncio
99
from wolframclient.utils.functional import map
1010

1111

wolframclient/evaluation/cloud/asynccloudsession.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
XAuthAIOHttpAsyncSession as XAuthAsyncSession,
1212
)
1313
from wolframclient.evaluation.cloud.base import WolframAPICallBase
14-
from wolframclient.evaluation.cloud.server import WOLFRAM_PUBLIC_CLOUD_SERVER, DEFAULT_CA_PATH
14+
from wolframclient.evaluation.cloud.server import DEFAULT_CA_PATH, WOLFRAM_PUBLIC_CLOUD_SERVER
1515
from wolframclient.evaluation.result import (
1616
WolframAPIResponseBuilder,
1717
WolframEvaluationWXFResponseAsync,
@@ -70,7 +70,6 @@ def __init__(
7070
else:
7171
self._ssl_context = None
7272

73-
7473
def duplicate(self):
7574
return self.__class__(
7675
credentials=self.credentials,

wolframclient/evaluation/cloud/asyncoauth.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import absolute_import, print_function, unicode_literals
22

33
import logging
4+
45
from wolframclient.evaluation.cloud.base import OAuthAsyncSessionBase, UserIDPassword
56
from wolframclient.evaluation.cloud.server import DEFAULT_CA_PATH
67
from wolframclient.exception import AuthenticationException

wolframclient/evaluation/cloud/server.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from __future__ import absolute_import, print_function, unicode_literals
22

33
from wolframclient.utils import six
4+
45
try:
56
import certifi
7+
68
DEFAULT_CA_PATH = certifi.where()
79
except ImportError:
810
certifi = None

wolframclient/serializers/encoder.py

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

8-
import pkg_resources
9-
108
from wolframclient.serializers.utils import safe_len
11-
from wolframclient.utils.api import multiprocessing
9+
from wolframclient.utils.api import multiprocessing, pkg_resources
1210
from wolframclient.utils.dispatch import Dispatch
1311
from wolframclient.utils.functional import composition, is_iterable, iterate, map
1412
from wolframclient.utils.importutils import safe_import_string

wolframclient/tests/deserializers/wxf_deserialize.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,11 @@ def test_bigreal_precision_exponent(self):
148148
self.assertEqual(res, decimal.Decimal("9.999999999999996843873323328588479844E+999"))
149149

150150
def test_bigreal_precision_negexponent(self):
151-
wxf = b'8:RC4.590261537982443550699999999999999999999281`19.66183743091127*^-16'
152-
res = binary_deserialize(wxf, consumer=WXFConsumer())
153-
self.assertEqual(res, decimal.Decimal('4.590261537982443550699999999999999999999281E-16'))
151+
wxf = b"8:RC4.590261537982443550699999999999999999999281`19.66183743091127*^-16"
152+
res = binary_deserialize(wxf, consumer=WXFConsumer())
153+
self.assertEqual(
154+
res, decimal.Decimal("4.590261537982443550699999999999999999999281E-16")
155+
)
154156

155157
def test_empty_lists(self):
156158
value = ((), ((),), (1, ()), ())

wolframclient/tests/evaluation/test_async_cloud.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ async def test_bad_sak_with(self):
143143

144144
def test_sslcontext(self):
145145
from wolframclient.evaluation.cloud.server import DEFAULT_CA_PATH
146+
146147
s = WolframCloudAsyncSession()
147148
if DEFAULT_CA_PATH is None:
148149
self.assertIsNone(s._ssl_context)

wolframclient/utils/api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@
148148
)
149149

150150
multiprocessing = API(Lock="wolframclient.utils.lock.Lock")
151+
pkg_resources = API(
152+
iter_entry_points=("pkg_resources.iter_entry_points", lambda *args, **opts: ())
153+
)
151154

152155
PIL = API(Image="PIL.Image.Image", fromarray="PIL.Image.fromarray", open="PIL.Image.open")
153156

@@ -177,10 +180,7 @@
177180
StringPayload="aiohttp.StringPayload",
178181
)
179182

180-
ssl = API(
181-
SSLContext="ssl.SSLContext",
182-
create_default_context="ssl.create_default_context",
183-
)
183+
ssl = API(SSLContext="ssl.SSLContext", create_default_context="ssl.create_default_context")
184184

185185
externalevaluate = API(
186186
execute_from_file="wolframclient.utils.externalevaluate.execute_from_file",

0 commit comments

Comments
 (0)