File tree 12 files changed +96
-22
lines changed
12 files changed +96
-22
lines changed Original file line number Diff line number Diff line change @@ -9,3 +9,6 @@ max_line_length = 80
9
9
10
10
[* .md ]
11
11
trim_trailing_whitespace = false
12
+
13
+ [* .{yaml,yml} ]
14
+ indent_size = 2
Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ name: Python package
2
2
3
3
on : [push, pull_request]
4
4
5
+ env :
6
+ DOCKER_BUILDKIT : ' 1'
7
+
5
8
jobs :
6
9
flake8 :
7
10
runs-on : ubuntu-latest
Original file line number Diff line number Diff line change
1
+ name : Release
2
+
3
+ on :
4
+ workflow_dispatch :
5
+ inputs :
6
+ tag :
7
+ description : " Release Tag WITHOUT `v` Prefix (e.g. 6.0.0)"
8
+ required : true
9
+ dry-run :
10
+ description : ' Dry run'
11
+ required : false
12
+ type : boolean
13
+ default : true
14
+
15
+ jobs :
16
+ publish :
17
+ runs-on : ubuntu-22.04
18
+ steps :
19
+ - uses : actions/checkout@v3
20
+
21
+ - uses : actions/setup-python@v4
22
+ with :
23
+ python-version : ' 3.10'
24
+
25
+ - run : python setup.py sdist bdist_wheel
26
+ env :
27
+ SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DOCKER : ${{ inputs.tag }}
28
+
29
+ - name : Publish to PyPI
30
+ uses : pypa/gh-action-pypi-publish@release/v1
31
+ if : ! inputs.dry-run
32
+ with :
33
+ password : ${{ secrets.PYPI_API_TOKEN }}
34
+
35
+ - name : Create GitHub release
36
+ uses : ncipollo/release-action@v1
37
+ if : ! inputs.dry-run
38
+ with :
39
+ artifacts : " dist/*"
40
+ generateReleaseNotes : true
41
+ draft : true
42
+ commit : ${{ github.sha }}
43
+ token : ${{ secrets.GITHUB_TOKEN }}
44
+ tag : ${{ inputs.tag }}
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ html/*
13
13
_build /
14
14
README.rst
15
15
16
+ # setuptools_scm
17
+ _version.py
18
+
16
19
env /
17
20
venv /
18
21
.idea /
22
+ * .iml
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ ARG PYTHON_VERSION=3.10
2
2
3
3
FROM python:${PYTHON_VERSION}
4
4
5
- RUN mkdir /src
6
5
WORKDIR /src
7
6
8
7
COPY requirements.txt /src/requirements.txt
@@ -11,5 +10,6 @@ RUN pip install --no-cache-dir -r requirements.txt
11
10
COPY test-requirements.txt /src/test-requirements.txt
12
11
RUN pip install --no-cache-dir -r test-requirements.txt
13
12
14
- COPY . /src
13
+ COPY . .
14
+ ARG SETUPTOOLS_SCM_PRETEND_VERSION_DOCKER
15
15
RUN pip install --no-cache-dir .
Original file line number Diff line number Diff line change 4
4
from .context import Context
5
5
from .context import ContextAPI
6
6
from .tls import TLSConfig
7
- from .version import version , version_info
7
+ from .version import __version__
8
8
9
- __version__ = version
10
9
__title__ = 'docker'
Original file line number Diff line number Diff line change 1
1
import sys
2
- from .version import version
2
+ from .version import __version__
3
3
4
4
DEFAULT_DOCKER_API_VERSION = '1.41'
5
5
MINIMUM_DOCKER_API_VERSION = '1.21'
28
28
IS_WINDOWS_PLATFORM = (sys .platform == 'win32' )
29
29
WINDOWS_LONGPATH_PREFIX = '\\ \\ ?\\ '
30
30
31
- DEFAULT_USER_AGENT = f"docker-sdk-python/{ version } "
31
+ DEFAULT_USER_AGENT = f"docker-sdk-python/{ __version__ } "
32
32
DEFAULT_NUM_POOLS = 25
33
33
34
34
# The OpenSSH server default value for MaxSessions is 10 which means we can
Original file line number Diff line number Diff line change 1
- version = "6.0.0-dev"
2
- version_info = tuple (int (d ) for d in version .split ("-" )[0 ].split ("." ))
1
+ try :
2
+ from ._version import __version__
3
+ except ImportError :
4
+ try :
5
+ # importlib.metadata available in Python 3.8+, the fallback (0.0.0)
6
+ # is fine because release builds use _version (above) rather than
7
+ # this code path, so it only impacts developing w/ 3.7
8
+ from importlib .metadata import version , PackageNotFoundError
9
+ try :
10
+ __version__ = version ('docker' )
11
+ except PackageNotFoundError :
12
+ __version__ = '0.0.0'
13
+ except ImportError :
14
+ __version__ = '0.0.0'
Original file line number Diff line number Diff line change 63
63
# |version| and |release|, also used in various other places throughout the
64
64
# built documents.
65
65
#
66
- with open ('../docker/version.py' ) as vfile :
67
- exec (vfile .read ())
68
- # The full version, including alpha/beta/rc tags.
69
- release = version
70
- # The short X.Y version.
71
- version = f'{ version_info [0 ]} .{ version_info [1 ]} '
66
+ # see https://github.com/pypa/setuptools_scm#usage-from-sphinx
67
+ from importlib .metadata import version
68
+ release = version ('docker' )
69
+ # for example take major/minor
70
+ version = '.' .join (release .split ('.' )[:2 ])
72
71
73
72
# The language for content autogenerated by Sphinx. Refer to documentation
74
73
# for a list of supported languages.
Original file line number Diff line number Diff line change
1
+ [build-system ]
2
+ requires = [" setuptools>=45" , " setuptools_scm[toml]>=6.2" ]
3
+
4
+ [tool .setuptools_scm ]
5
+ write_to = ' docker/_version.py'
Original file line number Diff line number Diff line change 29
29
'ssh' : ['paramiko>=2.4.3' ],
30
30
}
31
31
32
- version = None
33
- exec (open ('docker/version.py' ).read ())
34
-
35
32
with open ('./test-requirements.txt' ) as test_reqs_txt :
36
33
test_requirements = [line for line in test_reqs_txt ]
37
34
42
39
43
40
setup (
44
41
name = "docker" ,
45
- version = version ,
42
+ use_scm_version = {
43
+ 'write_to' : 'docker/_version.py'
44
+ },
46
45
description = "A Python library for the Docker Engine API." ,
47
46
long_description = long_description ,
48
47
long_description_content_type = 'text/markdown' ,
54
53
'Tracker' : 'https://github.com/docker/docker-py/issues' ,
55
54
},
56
55
packages = find_packages (exclude = ["tests.*" , "tests" ]),
56
+ setup_requires = ['setuptools_scm' ],
57
57
install_requires = requirements ,
58
58
tests_require = test_requirements ,
59
59
extras_require = extras_require ,
Original file line number Diff line number Diff line change
1
+ # syntax = docker/dockerfile:1.4
1
2
ARG PYTHON_VERSION=3.10
2
-
3
3
FROM python:${PYTHON_VERSION}
4
4
5
5
ARG APT_MIRROR
@@ -29,11 +29,16 @@ RUN curl -sSL -o /opt/docker-credential-pass.tar.gz \
29
29
chmod +x /usr/local/bin/docker-credential-pass
30
30
31
31
WORKDIR /src
32
+
32
33
COPY requirements.txt /src/requirements.txt
33
- RUN pip install -r requirements.txt
34
+ RUN --mount=type=cache,target=/root/.cache/pip \
35
+ pip install -r requirements.txt
34
36
35
37
COPY test-requirements.txt /src/test-requirements.txt
36
- RUN pip install -r test-requirements.txt
38
+ RUN --mount=type=cache,target=/root/.cache/pip \
39
+ pip install -r test-requirements.txt
37
40
38
41
COPY . /src
39
- RUN pip install .
42
+ ARG SETUPTOOLS_SCM_PRETEND_VERSION=99.0.0-docker
43
+ RUN --mount=type=cache,target=/root/.cache/pip \
44
+ pip install -e .
You can’t perform that action at this time.
0 commit comments