Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make python 3.6 the minimum version #2788

Merged
merged 1 commit into from
Mar 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
max-parallel: 1
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9]
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand All @@ -18,8 +18,8 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r test-requirements.txt -r requirements.txt
python3 -m pip install --upgrade pip
pip3 install -r test-requirements.txt -r requirements.txt
- name: Test with pytest
run: |
docker logout
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sphinx:
configuration: docs/conf.py

python:
version: 3.5
version: 3.6
install:
- requirements: docs-requirements.txt
- requirements: requirements.txt
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
ARG PYTHON_VERSION=2.7
ARG PYTHON_VERSION=3.7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be 3.6?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this one, it's the version on which it will be compiled. Doesn't have a relationship with the minimal version


FROM python:${PYTHON_VERSION}

# Add SSH keys and set permissions
COPY tests/ssh-keys /root/.ssh
RUN chmod -R 600 /root/.ssh

RUN mkdir /src
WORKDIR /src

Expand Down
15 changes: 0 additions & 15 deletions Dockerfile-py3

This file was deleted.

5 changes: 1 addition & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!groovy

def imageNameBase = "dockerpinata/docker-py"
def imageNamePy2
def imageNamePy3
def imageDindSSH
def images = [:]
Expand All @@ -22,12 +21,10 @@ def buildImages = { ->
stage("build image") {
checkout(scm)

imageNamePy2 = "${imageNameBase}:py2-${gitCommit()}"
imageNamePy3 = "${imageNameBase}:py3-${gitCommit()}"
imageDindSSH = "${imageNameBase}:sshdind-${gitCommit()}"
withDockerRegistry(credentialsId:'dockerbuildbot-index.docker.io') {
buildImage(imageDindSSH, "-f tests/Dockerfile-ssh-dind .", "")
buildImage(imageNamePy2, "-f tests/Dockerfile --build-arg PYTHON_VERSION=2.7 .", "py2.7")
buildImage(imageNamePy3, "-f tests/Dockerfile --build-arg PYTHON_VERSION=3.7 .", "py3.7")
}
}
Expand Down Expand Up @@ -73,7 +70,7 @@ def runTests = { Map settings ->
throw new Exception("Need Docker version to test, e.g.: `runTests(dockerVersion: '19.03.12')`")
}
if (!pythonVersion) {
throw new Exception("Need Python version being tested, e.g.: `runTests(pythonVersion: 'py2.7')`")
throw new Exception("Need Python version being tested, e.g.: `runTests(pythonVersion: 'py3.7')`")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too 3.6

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is the same as above. It's the version on which it will be tested. Not released.

}

{ ->
Expand Down
50 changes: 8 additions & 42 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ all: test

.PHONY: clean
clean:
-docker rm -f dpy-dind-py2 dpy-dind-py3 dpy-dind-certs dpy-dind-ssl
-docker rm -f dpy-dind-py3 dpy-dind-certs dpy-dind-ssl
find -name "__pycache__" | xargs rm -rf

.PHONY: build
build:
docker build -t docker-sdk-python -f tests/Dockerfile --build-arg PYTHON_VERSION=2.7 --build-arg APT_MIRROR .

.PHONY: build-dind-ssh
build-dind-ssh:
docker build -t docker-dind-ssh -f tests/Dockerfile-ssh-dind --build-arg ENGINE_VERSION=${TEST_ENGINE_VERSION} --build-arg API_VERSION=${TEST_API_VERSION} --build-arg APT_MIRROR .
Expand All @@ -30,20 +26,12 @@ build-dind-certs:
docker build -t dpy-dind-certs -f tests/Dockerfile-dind-certs .

.PHONY: test
test: flake8 unit-test unit-test-py3 integration-dind integration-dind-ssl

.PHONY: unit-test
unit-test: build
docker run -t --rm docker-sdk-python py.test tests/unit
test: flake8 unit-test-py3 integration-dind integration-dind-ssl

.PHONY: unit-test-py3
unit-test-py3: build-py3
docker run -t --rm docker-sdk-python3 py.test tests/unit

.PHONY: integration-test
integration-test: build
docker run -t --rm -v /var/run/docker.sock:/var/run/docker.sock docker-sdk-python py.test -v tests/integration/${file}

.PHONY: integration-test-py3
integration-test-py3: build-py3
docker run -t --rm -v /var/run/docker.sock:/var/run/docker.sock docker-sdk-python3 py.test -v tests/integration/${file}
Expand All @@ -53,16 +41,7 @@ setup-network:
docker network inspect dpy-tests || docker network create dpy-tests

.PHONY: integration-dind
integration-dind: integration-dind-py2 integration-dind-py3

.PHONY: integration-dind-py2
integration-dind-py2: build setup-network
docker rm -vf dpy-dind-py2 || :
docker run -d --network dpy-tests --name dpy-dind-py2 --privileged\
docker:${TEST_ENGINE_VERSION}-dind dockerd -H tcp://0.0.0.0:2375 --experimental
docker run -t --rm --env="DOCKER_HOST=tcp://dpy-dind-py2:2375" --env="DOCKER_TEST_API_VERSION=${TEST_API_VERSION}"\
--network dpy-tests docker-sdk-python py.test tests/integration/${file}
docker rm -vf dpy-dind-py2
integration-dind: integration-dind-py3

.PHONY: integration-dind-py3
integration-dind-py3: build-py3 setup-network
Expand All @@ -73,16 +52,6 @@ integration-dind-py3: build-py3 setup-network
--network dpy-tests docker-sdk-python3 py.test tests/integration/${file}
docker rm -vf dpy-dind-py3

.PHONY: integration-ssh-py2
integration-ssh-py2: build-dind-ssh build setup-network
docker rm -vf dpy-dind-py2 || :
docker run -d --network dpy-tests --name dpy-dind-py2 --privileged\
docker-dind-ssh dockerd --experimental
# start SSH daemon
docker exec dpy-dind-py2 sh -c "/usr/sbin/sshd"
docker run -t --rm --env="DOCKER_HOST=ssh://dpy-dind-py2" --env="DOCKER_TEST_API_VERSION=${TEST_API_VERSION}"\
--network dpy-tests docker-sdk-python py.test tests/ssh/${file}
docker rm -vf dpy-dind-py2

.PHONY: integration-ssh-py3
integration-ssh-py3: build-dind-ssh build-py3 setup-network
Expand All @@ -97,7 +66,7 @@ integration-ssh-py3: build-dind-ssh build-py3 setup-network


.PHONY: integration-dind-ssl
integration-dind-ssl: build-dind-certs build build-py3
integration-dind-ssl: build-dind-certs build-py3
docker rm -vf dpy-dind-certs dpy-dind-ssl || :
docker run -d --name dpy-dind-certs dpy-dind-certs
docker run -d --env="DOCKER_HOST=tcp://localhost:2375" --env="DOCKER_TLS_VERIFY=1"\
Expand All @@ -106,22 +75,19 @@ integration-dind-ssl: build-dind-certs build build-py3
docker:${TEST_ENGINE_VERSION}-dind\
dockerd --tlsverify --tlscacert=/certs/ca.pem --tlscert=/certs/server-cert.pem\
--tlskey=/certs/server-key.pem -H tcp://0.0.0.0:2375 --experimental
docker run -t --rm --volumes-from dpy-dind-ssl --env="DOCKER_HOST=tcp://docker:2375"\
--env="DOCKER_TLS_VERIFY=1" --env="DOCKER_CERT_PATH=/certs" --env="DOCKER_TEST_API_VERSION=${TEST_API_VERSION}"\
--network dpy-tests docker-sdk-python py.test tests/integration/${file}
docker run -t --rm --volumes-from dpy-dind-ssl --env="DOCKER_HOST=tcp://docker:2375"\
--env="DOCKER_TLS_VERIFY=1" --env="DOCKER_CERT_PATH=/certs" --env="DOCKER_TEST_API_VERSION=${TEST_API_VERSION}"\
--network dpy-tests docker-sdk-python3 py.test tests/integration/${file}
docker rm -vf dpy-dind-ssl dpy-dind-certs

.PHONY: flake8
flake8: build
docker run -t --rm docker-sdk-python flake8 docker tests
flake8: build-py3
docker run -t --rm docker-sdk-python3 flake8 docker tests

.PHONY: docs
docs: build-docs
docker run --rm -t -v `pwd`:/src docker-sdk-python-docs sphinx-build docs docs/_build

.PHONY: shell
shell: build
docker run -it -v /var/run/docker.sock:/var/run/docker.sock docker-sdk-python python
shell: build-py3
docker run -it -v /var/run/docker.sock:/var/run/docker.sock docker-sdk-python3 python
18 changes: 8 additions & 10 deletions docker/api/client.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import json
import struct
import urllib
from functools import partial

import requests
import requests.exceptions
import six
import websocket

from .. import auth
Expand Down Expand Up @@ -192,12 +192,12 @@ def __init__(self, base_url=None, version=None,
# version detection needs to be after unix adapter mounting
if version is None or (isinstance(
version,
six.string_types
str
) and version.lower() == 'auto'):
self._version = self._retrieve_server_version()
else:
self._version = version
if not isinstance(self._version, six.string_types):
if not isinstance(self._version, str):
raise DockerException(
'Version parameter must be a string or None. Found {0}'.format(
type(version).__name__
Expand Down Expand Up @@ -246,13 +246,13 @@ def _delete(self, url, **kwargs):

def _url(self, pathfmt, *args, **kwargs):
for arg in args:
if not isinstance(arg, six.string_types):
if not isinstance(arg, str):
raise ValueError(
'Expected a string but found {0} ({1}) '
'instead'.format(arg, type(arg))
)

quote_f = partial(six.moves.urllib.parse.quote, safe="/:")
quote_f = partial(urllib.parse.quote, safe="/:")
args = map(quote_f, args)

if kwargs.get('versioned_api', True):
Expand Down Expand Up @@ -284,7 +284,7 @@ def _post_json(self, url, data, **kwargs):
# so we do this disgusting thing here.
data2 = {}
if data is not None and isinstance(data, dict):
for k, v in six.iteritems(data):
for k, v in iter(data.items()):
if v is not None:
data2[k] = v
elif data is not None:
Expand Down Expand Up @@ -320,12 +320,10 @@ def _get_raw_response_socket(self, response):
sock = response.raw._fp.fp.raw.sock
elif self.base_url.startswith('http+docker://ssh'):
sock = response.raw._fp.fp.channel
elif six.PY3:
else:
sock = response.raw._fp.fp.raw
if self.base_url.startswith("https://"):
sock = sock._sock
else:
sock = response.raw._fp.fp._sock
try:
# Keep a reference to the response to stop it being garbage
# collected. If the response is garbage collected, it will
Expand Down Expand Up @@ -465,7 +463,7 @@ def _get_result_tty(self, stream, res, is_tty):
self._result(res, binary=True)

self._raise_for_status(res)
sep = six.binary_type()
sep = b''
if stream:
return self._multiplexed_response_stream_helper(res)
else:
Expand Down
7 changes: 4 additions & 3 deletions docker/context/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

class Context:
"""A context."""

def __init__(self, name, orchestrator=None, host=None, endpoints=None,
tls=False):
if not name:
Expand Down Expand Up @@ -128,9 +129,9 @@ def _load_certs(self):
key = os.path.join(tls_dir, endpoint, filename)
if all([ca_cert, cert, key]):
verify = None
if endpoint == "docker":
if not self.endpoints["docker"].get("SkipTLSVerify", False):
verify = True
if endpoint == "docker" and not self.endpoints["docker"].get(
"SkipTLSVerify", False):
verify = True
certs[endpoint] = TLSConfig(
client_cert=(cert, key), ca_cert=ca_cert, verify=verify)
self.tls_cfg = certs
Expand Down
4 changes: 2 additions & 2 deletions docker/transport/sshconn.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def f():
signal.signal(signal.SIGINT, signal.SIG_IGN)
preexec_func = f

env = dict(os.environ)
env = dict(os.environ)

# drop LD_LIBRARY_PATH and SSL_CERT_FILE
env.pop('LD_LIBRARY_PATH', None)
Expand All @@ -65,7 +65,7 @@ def f():
shell=True,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
preexec_fn=preexec_func)
preexec_fn=None if constants.IS_WINDOWS_PLATFORM else preexec_func)

def _write(self, data):
if not self.proc or self.proc.stdin.closed:
Expand Down