From f128956034b2df1f8741e4c0246f79e1e2598146 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Thu, 21 Dec 2023 10:35:28 +0200 Subject: [PATCH 1/6] Use `build` instead of calling setup.py Signed-off-by: Aarni Koskela --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 721020ac3..6987fce0d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,10 +26,10 @@ jobs: with: python-version: '3.x' - - name: Generate Pacakge + - name: Generate Package run: | - pip3 install setuptools wheel - python setup.py sdist bdist_wheel + pip3 install build + python -m build . env: SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DOCKER: ${{ inputs.tag }} From ae45d477c44b880cdc7155f8829e0cdea84d0033 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Thu, 21 Dec 2023 10:37:23 +0200 Subject: [PATCH 2/6] Use `hatch` for packaging Signed-off-by: Aarni Koskela --- .github/workflows/release.yml | 2 + pyproject.toml | 64 +++++++++++++++++++++++++-- setup.cfg | 3 -- setup.py | 82 ----------------------------------- 4 files changed, 63 insertions(+), 88 deletions(-) delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6987fce0d..953b59bf7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,6 +31,8 @@ jobs: pip3 install build python -m build . env: + # This is also supported by Hatch; see + # https://github.com/ofek/hatch-vcs#version-source-environment-variables SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DOCKER: ${{ inputs.tag }} - name: Publish to PyPI diff --git a/pyproject.toml b/pyproject.toml index a64e120ee..83d22b801 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,66 @@ [build-system] -requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" -[tool.setuptools_scm] -write_to = 'docker/_version.py' +[project] +name = "docker" +dynamic = ["version"] +description = "A Python library for the Docker Engine API." +readme = "README.md" +license = "Apache-2.0" +requires-python = ">=3.8" +maintainers = [ + { name = "Docker Inc.", email = "no-reply@docker.com" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Other Environment", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development", + "Topic :: Utilities", +] + +dependencies = [ + "requests >= 2.26.0", + "urllib3 >= 1.26.0", + "pywin32>=304; sys_platform == \"win32\"", +] + +[project.optional-dependencies] +ssh = [ + "paramiko>=2.4.3", +] +tls = [] # kept for backwards compatibility +websockets = [ + "websocket-client >= 1.3.0", +] + +[project.urls] +Changelog = "https://docker-py.readthedocs.io/en/stable/change-log.html" +Documentation = "https://docker-py.readthedocs.io" +Homepage = "https://github.com/docker/docker-py" +Source = "https://github.com/docker/docker-py" +Tracker = "https://github.com/docker/docker-py/issues" + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "docker/_version.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/docker", +] [tool.ruff] target-version = "py38" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index a37e5521d..000000000 --- a/setup.cfg +++ /dev/null @@ -1,3 +0,0 @@ -[metadata] -description_file = README.rst -license = Apache License 2.0 diff --git a/setup.py b/setup.py deleted file mode 100644 index 3d3313924..000000000 --- a/setup.py +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env python - -import codecs -import os - -from setuptools import find_packages -from setuptools import setup - -ROOT_DIR = os.path.dirname(__file__) -SOURCE_DIR = os.path.join(ROOT_DIR) - -requirements = [ - 'requests >= 2.26.0', - 'urllib3 >= 1.26.0', -] - -extras_require = { - # win32 APIs if on Windows (required for npipe support) - ':sys_platform == "win32"': 'pywin32>=304', - - # This is now a no-op, as similarly the requests[security] extra is - # a no-op as of requests 2.26.0, this is always available/by default now - # see https://github.com/psf/requests/pull/5867 - 'tls': [], - - # Only required when connecting using the ssh:// protocol - '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: - test_requirements = list(test_reqs_txt) - - -long_description = '' -with codecs.open('./README.md', encoding='utf-8') as readme_md: - long_description = readme_md.read() - -setup( - name="docker", - use_scm_version={ - 'write_to': 'docker/_version.py' - }, - description="A Python library for the Docker Engine API.", - long_description=long_description, - long_description_content_type='text/markdown', - url='https://github.com/docker/docker-py', - project_urls={ - 'Documentation': 'https://docker-py.readthedocs.io', - 'Changelog': 'https://docker-py.readthedocs.io/en/stable/change-log.html', - 'Source': 'https://github.com/docker/docker-py', - 'Tracker': 'https://github.com/docker/docker-py/issues', - }, - packages=find_packages(exclude=["tests.*", "tests"]), - setup_requires=['setuptools_scm'], - install_requires=requirements, - tests_require=test_requirements, - extras_require=extras_require, - python_requires='>=3.8', - zip_safe=False, - test_suite='tests', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Other Environment', - 'Intended Audience :: Developers', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Topic :: Software Development', - 'Topic :: Utilities', - 'License :: OSI Approved :: Apache Software License', - ], - maintainer='Docker, Inc.', - maintainer_email='no-reply@docker.com', -) From 047df6b0d31250d5d15ce25d1252ea7a04c7fcd4 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Thu, 21 Dec 2023 10:51:05 +0200 Subject: [PATCH 3/6] Build wheel in CI, upload artifact for perusal Signed-off-by: Aarni Koskela --- .github/workflows/ci.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 628c53504..9eb450a6a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,19 @@ jobs: - name: Run ruff run: ruff docker tests + build: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: '3.x' + - run: pip3 install build && python -m build . + - uses: actions/upload-artifact@v4 + with: + name: dist + path: dist + unit-tests: runs-on: ubuntu-latest strategy: From cb21af7f69fc44572c9f9a326c84275ae2be9c63 Mon Sep 17 00:00:00 2001 From: Rob Murray Date: Wed, 13 Mar 2024 14:54:25 +0000 Subject: [PATCH 4/6] Fix tests that look at 'Aliases' Inspect output for 'NetworkSettings.Networks..Aliases' includes the container's short-id (although it will be removed in API v1.45, in moby 26.0). Signed-off-by: Rob Murray --- tests/integration/models_containers_test.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/integration/models_containers_test.py b/tests/integration/models_containers_test.py index 219b9a4cb..87ba89b1d 100644 --- a/tests/integration/models_containers_test.py +++ b/tests/integration/models_containers_test.py @@ -110,12 +110,12 @@ def test_run_with_networking_config(self): client.networks.create(net_name) self.tmp_networks.append(net_name) - test_aliases = ['hello'] + test_alias = 'hello' test_driver_opt = {'key1': 'a'} networking_config = { net_name: client.api.create_endpoint_config( - aliases=test_aliases, + aliases=[test_alias], driver_opt=test_driver_opt ) } @@ -132,8 +132,10 @@ def test_run_with_networking_config(self): assert 'NetworkSettings' in attrs assert 'Networks' in attrs['NetworkSettings'] assert list(attrs['NetworkSettings']['Networks'].keys()) == [net_name] - assert attrs['NetworkSettings']['Networks'][net_name]['Aliases'] == \ - test_aliases + # Expect Aliases to list 'test_alias' and the container's short-id. + # In API version 1.45, the short-id will be removed. + assert attrs['NetworkSettings']['Networks'][net_name]['Aliases'] \ + == [test_alias, attrs['Id'][:12]] assert attrs['NetworkSettings']['Networks'][net_name]['DriverOpts'] \ == test_driver_opt @@ -190,7 +192,9 @@ def test_run_with_networking_config_only_undeclared_network(self): assert 'NetworkSettings' in attrs assert 'Networks' in attrs['NetworkSettings'] assert list(attrs['NetworkSettings']['Networks'].keys()) == [net_name] - assert attrs['NetworkSettings']['Networks'][net_name]['Aliases'] is None + # Aliases should include the container's short-id (but it will be removed + # in API v1.45). + assert attrs['NetworkSettings']['Networks'][net_name]['Aliases'] == [attrs["Id"][:12]] assert (attrs['NetworkSettings']['Networks'][net_name]['DriverOpts'] is None) From e91b280074784026135573ab1726a565c090cd82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Thu, 7 Mar 2024 13:12:32 +0100 Subject: [PATCH 5/6] Bump default API version to 1.44 (Moby 25.0) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Gronowski --- Makefile | 4 ++-- docker/constants.py | 2 +- tests/Dockerfile-ssh-dind | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 00ebca05c..25a83205b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -TEST_API_VERSION ?= 1.43 -TEST_ENGINE_VERSION ?= 24.0 +TEST_API_VERSION ?= 1.44 +TEST_ENGINE_VERSION ?= 25.0 ifeq ($(OS),Windows_NT) PLATFORM := Windows diff --git a/docker/constants.py b/docker/constants.py index 71e543e53..8e7350d3d 100644 --- a/docker/constants.py +++ b/docker/constants.py @@ -1,7 +1,7 @@ import sys from .version import __version__ -DEFAULT_DOCKER_API_VERSION = '1.43' +DEFAULT_DOCKER_API_VERSION = '1.44' MINIMUM_DOCKER_API_VERSION = '1.21' DEFAULT_TIMEOUT_SECONDS = 60 STREAM_HEADER_SIZE_BYTES = 8 diff --git a/tests/Dockerfile-ssh-dind b/tests/Dockerfile-ssh-dind index 2b7332b8b..250c20f2c 100644 --- a/tests/Dockerfile-ssh-dind +++ b/tests/Dockerfile-ssh-dind @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:1 -ARG API_VERSION=1.43 -ARG ENGINE_VERSION=24.0 +ARG API_VERSION=1.44 +ARG ENGINE_VERSION=25.0 FROM docker:${ENGINE_VERSION}-dind From dd82f9ae8e601d3c82ef8d4f2dbab0c16109152f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Thu, 7 Mar 2024 13:12:45 +0100 Subject: [PATCH 6/6] Bump minimum API version to 1.24 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 25.0 raised the minimum supported API verison: https://github.com/moby/moby/pull/46887 Signed-off-by: Paweł Gronowski --- docker/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/constants.py b/docker/constants.py index 8e7350d3d..213ff61ed 100644 --- a/docker/constants.py +++ b/docker/constants.py @@ -2,7 +2,7 @@ from .version import __version__ DEFAULT_DOCKER_API_VERSION = '1.44' -MINIMUM_DOCKER_API_VERSION = '1.21' +MINIMUM_DOCKER_API_VERSION = '1.24' DEFAULT_TIMEOUT_SECONDS = 60 STREAM_HEADER_SIZE_BYTES = 8 CONTAINER_LIMITS_KEYS = [