From 47f4c8196401ef48dd8017bd8e214bbec9699f94 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Thu, 21 Dec 2023 10:37:23 +0200 Subject: [PATCH] Use `hatch` for packaging Signed-off-by: Aarni Koskela --- .github/workflows/release.yml | 2 + pyproject.toml | 64 +++++++++++++++++++++++++-- setup.cfg | 3 -- setup.py | 83 ----------------------------------- 4 files changed, 63 insertions(+), 89 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 0a6727966..eaf478c81 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 = "py37" 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 b6a024f81..000000000 --- a/setup.py +++ /dev/null @@ -1,83 +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 = [ - 'packaging >= 14.0', - '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', -)