mirror of https://github.com/docker/docker-py.git
feat: move websocket-client to extra dependency (#3123)
Also bump minimum version to that prescribed by #3022 Signed-off-by: Aarni Koskela <akx@iki.fi>
This commit is contained in:
parent
4a88112345
commit
c9e3efddb8
|
@ -5,7 +5,6 @@ from functools import partial
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import requests.exceptions
|
import requests.exceptions
|
||||||
import websocket
|
|
||||||
|
|
||||||
from .. import auth
|
from .. import auth
|
||||||
from ..constants import (DEFAULT_NUM_POOLS, DEFAULT_NUM_POOLS_SSH,
|
from ..constants import (DEFAULT_NUM_POOLS, DEFAULT_NUM_POOLS_SSH,
|
||||||
|
@ -309,7 +308,16 @@ class APIClient(
|
||||||
return self._create_websocket_connection(full_url)
|
return self._create_websocket_connection(full_url)
|
||||||
|
|
||||||
def _create_websocket_connection(self, url):
|
def _create_websocket_connection(self, url):
|
||||||
return websocket.create_connection(url)
|
try:
|
||||||
|
import websocket
|
||||||
|
return websocket.create_connection(url)
|
||||||
|
except ImportError as ie:
|
||||||
|
raise DockerException(
|
||||||
|
'The `websocket-client` library is required '
|
||||||
|
'for using websocket connections. '
|
||||||
|
'You can install the `docker` library '
|
||||||
|
'with the [websocket] extra to install it.'
|
||||||
|
) from ie
|
||||||
|
|
||||||
def _get_raw_response_socket(self, response):
|
def _get_raw_response_socket(self, response):
|
||||||
self._raise_for_status(response)
|
self._raise_for_status(response)
|
||||||
|
|
4
setup.py
4
setup.py
|
@ -13,7 +13,6 @@ requirements = [
|
||||||
'packaging >= 14.0',
|
'packaging >= 14.0',
|
||||||
'requests >= 2.26.0',
|
'requests >= 2.26.0',
|
||||||
'urllib3 >= 1.26.0',
|
'urllib3 >= 1.26.0',
|
||||||
'websocket-client >= 0.32.0',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
extras_require = {
|
extras_require = {
|
||||||
|
@ -27,6 +26,9 @@ extras_require = {
|
||||||
|
|
||||||
# Only required when connecting using the ssh:// protocol
|
# Only required when connecting using the ssh:// protocol
|
||||||
'ssh': ['paramiko>=2.4.3'],
|
'ssh': ['paramiko>=2.4.3'],
|
||||||
|
|
||||||
|
# Only required when using websockets
|
||||||
|
'websockets': ['websocket-client >= 1.3.0'],
|
||||||
}
|
}
|
||||||
|
|
||||||
with open('./test-requirements.txt') as test_reqs_txt:
|
with open('./test-requirements.txt') as test_reqs_txt:
|
||||||
|
|
Loading…
Reference in New Issue