Skip to content

Commit 05a3567

Browse files
committed
Merge branch 'release/B12_1_0' into bugfix/380061-removing-dependencies
2 parents ce61048 + 22e06ef commit 05a3567

9 files changed

Lines changed: 35 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Version 1.1.3
2+
- Async cloud evaluator based on `aiohttp` now use `certifi` to create a default `SSLContext` if none is provided. Other cloud evaluator are based on the `requests` module which also uses this library.
3+
- Updating dependency list accordingly in `setup.py`. `certifi` was already listed as a `requests` dependency, so this should have no direct impact on user site package.
4+
# Version 1.1.3
25
- Update asynchronous evaluator classes. Remove the `loop` parameter. Most optional loop parameters are deprecated in the Python standart library `asyncio` and in most libraries, mainly because it is misleading and lead to misuses and bugs. The loop parameter is useful when instantiating asynchronous evaluators outside the scope of an event loop. It's implementation was not good enough and was relying on usages deprecated in 3.8.
36
- Removing four asynchronous generators in asynchronous evaluation result classes: `iter_messages`, `iter_messages_name`, `iter_messages_tuple` and `iter_output`. These coroutines are only working on python 3.6+ and are not critical enough to drop support for 3.5. Asynchronous properties: `messages`, `messages_name` and `output` provide the same information.
47

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def load_tests():
6767
'aiohttp',
6868
'oauthlib',
6969
'pyzmq',
70+
'certifi>=2017.4.17' # for consistency with requests module.
7071
],
7172
classifiers = CLASSIFIERS,
7273
project_urls={

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.3"
5+
__version__ = "1.1.4"
66
__author__ = "Wolfram Research"
77
__author_email__ = "support@wolfram.com, dorianb@wolfram.com, riccardod@wolfram.com"

wolframclient/evaluation/cloud/asynccloudsession.py

Lines changed: 4 additions & 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
14+
from wolframclient.evaluation.cloud.server import WOLFRAM_PUBLIC_CLOUD_SERVER, DEFAULT_CA_PATH
1515
from wolframclient.evaluation.result import (
1616
WolframAPIResponseBuilder,
1717
WolframEvaluationWXFResponseAsync,
@@ -65,10 +65,12 @@ def __init__(
6565
if self.server.certificate is not None:
6666
self._ssl_context = self.ssl_context_class()
6767
self._ssl_context.load_verify_locations(self.server.certificate)
68-
# self._ssl_context = ssl.create_default_context(cafile=self.server.certificate)
68+
elif DEFAULT_CA_PATH:
69+
self._ssl_context = ssl.create_default_context(cafile=DEFAULT_CA_PATH)
6970
else:
7071
self._ssl_context = None
7172

73+
7274
def duplicate(self):
7375
return self.__class__(
7476
credentials=self.credentials,

wolframclient/evaluation/cloud/asyncoauth.py

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

33
import logging
4-
54
from wolframclient.evaluation.cloud.base import OAuthAsyncSessionBase, UserIDPassword
5+
from wolframclient.evaluation.cloud.server import DEFAULT_CA_PATH
66
from wolframclient.exception import AuthenticationException
77
from wolframclient.utils import six
88
from wolframclient.utils.api import aiohttp, oauth, ssl
@@ -35,7 +35,8 @@ def __init__(
3535
if self.server.certificate is not None:
3636
self._ssl_context = self.ssl_context_class()
3737
self._ssl_context.load_verify_locations(self.server.certificate)
38-
# self._ssl_context = ssl.create_default_context(cafile=self.server.certificate)
38+
elif DEFAULT_CA_PATH:
39+
self._ssl_context = ssl.create_default_context(cafile=DEFAULT_CA_PATH)
3940
else:
4041
self._ssl_context = None
4142

wolframclient/evaluation/cloud/server.py

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

33
from wolframclient.utils import six
4+
try:
5+
import certifi
6+
DEFAULT_CA_PATH = certifi.where()
7+
except ImportError:
8+
certifi = None
9+
DEFAULT_CA_PATH = None
410

5-
__all__ = ["WolframServer"]
11+
12+
__all__ = ["WolframServer", "DEFAULT_CA_PATH"]
613

714

815
class WolframServer(object):

wolframclient/tests/evaluation/test_async_cloud.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,14 @@ async def test_bad_sak_with(self):
141141
) as cloud_session:
142142
cloud_session.authorized()
143143

144+
def test_sslcontext(self):
145+
from wolframclient.evaluation.cloud.server import DEFAULT_CA_PATH
146+
s = WolframCloudAsyncSession()
147+
if DEFAULT_CA_PATH is None:
148+
self.assertIsNone(s._ssl_context)
149+
else:
150+
self.assertIsNotNone(s._ssl_context)
151+
144152
@run_in_loop
145153
async def test_section_api_call_no_param(self):
146154
url = "api/private/requesterid"

wolframclient/utils/api.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,10 @@
169169
StringPayload="aiohttp.StringPayload",
170170
)
171171

172-
ssl = API(SSLContext="ssl.SSLContext")
172+
ssl = API(
173+
SSLContext="ssl.SSLContext",
174+
create_default_context="ssl.create_default_context",
175+
)
173176

174177
externalevaluate = API(
175178
execute_from_file="wolframclient.utils.externalevaluate.execute_from_file",

wolframclient/utils/lock.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
try:
66
_lock = safe_import_string_and_call('multithreading.Lock')
7+
78
def Lock():
89
return _lock
910

@@ -15,7 +16,8 @@ def Lock():
1516
from contextlib import contextmanager
1617
import warnings
1718

19+
warnings.warn("Lock is not implemented in the current interpreter.", RuntimeWarning)
20+
1821
@contextmanager
1922
def Lock():
20-
warnings.warn("Lock is not implemented in the current interpreter.", RuntimeWarning)
2123
yield

0 commit comments

Comments
 (0)