summaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
authorMilas Bowman <milas.bowman@docker.com>2022-07-30 12:14:27 -0400
committerGitHub <noreply@github.com>2022-07-30 12:14:27 -0400
commitcd2c35a9b699522b282cc4f024efa5699df24896 (patch)
tree18717584169b7cbbd1196be5fe327dd36136aad7 /docker
parent828d06f5f5e2c8ecd9a8d53c1ef40f37d19a62f5 (diff)
downloaddocker-py-cd2c35a9b699522b282cc4f024efa5699df24896.tar.gz
ci: add workflow for releases (#3018)
GitHub Actions workflow to create a release: will upload to PyPI and create a GitHub release with the `sdist` and `bdist_wheel` as well. The version code is switched to `setuptools_scm` to work well with this flow (e.g. avoid needing to write a script that does a `sed` on the version file and commits as part of release). Signed-off-by: Milas Bowman <milas.bowman@docker.com>
Diffstat (limited to 'docker')
-rw-r--r--docker/__init__.py3
-rw-r--r--docker/constants.py4
-rw-r--r--docker/version.py16
3 files changed, 17 insertions, 6 deletions
diff --git a/docker/__init__.py b/docker/__init__.py
index e5c1a8f..46beb53 100644
--- a/docker/__init__.py
+++ b/docker/__init__.py
@@ -4,7 +4,6 @@ from .client import DockerClient, from_env
from .context import Context
from .context import ContextAPI
from .tls import TLSConfig
-from .version import version, version_info
+from .version import __version__
-__version__ = version
__title__ = 'docker'
diff --git a/docker/constants.py b/docker/constants.py
index d5bfc35..ed341a9 100644
--- a/docker/constants.py
+++ b/docker/constants.py
@@ -1,5 +1,5 @@
import sys
-from .version import version
+from .version import __version__
DEFAULT_DOCKER_API_VERSION = '1.41'
MINIMUM_DOCKER_API_VERSION = '1.21'
@@ -28,7 +28,7 @@ INSECURE_REGISTRY_DEPRECATION_WARNING = \
IS_WINDOWS_PLATFORM = (sys.platform == 'win32')
WINDOWS_LONGPATH_PREFIX = '\\\\?\\'
-DEFAULT_USER_AGENT = f"docker-sdk-python/{version}"
+DEFAULT_USER_AGENT = f"docker-sdk-python/{__version__}"
DEFAULT_NUM_POOLS = 25
# The OpenSSH server default value for MaxSessions is 10 which means we can
diff --git a/docker/version.py b/docker/version.py
index 88ee8b0..44eac8c 100644
--- a/docker/version.py
+++ b/docker/version.py
@@ -1,2 +1,14 @@
-version = "6.0.0-dev"
-version_info = tuple(int(d) for d in version.split("-")[0].split("."))
+try:
+ from ._version import __version__
+except ImportError:
+ try:
+ # importlib.metadata available in Python 3.8+, the fallback (0.0.0)
+ # is fine because release builds use _version (above) rather than
+ # this code path, so it only impacts developing w/ 3.7
+ from importlib.metadata import version, PackageNotFoundError
+ try:
+ __version__ = version('docker')
+ except PackageNotFoundError:
+ __version__ = '0.0.0'
+ except ImportError:
+ __version__ = '0.0.0'