|
3 | 3 | builds via :py:class:`MultiStageBuild`. |
4 | 4 |
|
5 | 5 | """ |
| 6 | +import sys |
6 | 7 | import tempfile |
7 | 8 | from dataclasses import dataclass |
8 | 9 | from os.path import basename |
9 | 10 | from os.path import join |
10 | 11 | from pathlib import Path |
11 | 12 | from string import Template |
12 | 13 | from subprocess import check_output |
| 14 | +from typing import cast |
13 | 15 | from typing import Dict |
14 | 16 | from typing import List |
15 | 17 | from typing import Optional |
|
18 | 20 |
|
19 | 21 | from _pytest.config import Config |
20 | 22 | from _pytest.mark.structures import ParameterSet |
| 23 | +from deprecation import deprecated |
21 | 24 | from pytest_container.container import Container |
22 | 25 | from pytest_container.container import container_and_marks_from_pytest_param |
23 | 26 | from pytest_container.container import DerivedContainer |
24 | 27 | from pytest_container.logging import _logger |
25 | 28 | from pytest_container.runtime import OciRuntimeBase |
26 | 29 | from pytest_container.runtime import ToParamMixin |
27 | 30 |
|
| 31 | +if sys.version_info >= (3, 8): |
| 32 | + from importlib import metadata |
| 33 | +else: |
| 34 | + import importlib_metadata as metadata |
| 35 | + |
28 | 36 |
|
29 | 37 | @dataclass(frozen=True) |
30 | 38 | class GitRepositoryBuild(ToParamMixin): |
@@ -83,6 +91,14 @@ def test_command(self) -> str: |
83 | 91 | return cd_cmd |
84 | 92 |
|
85 | 93 |
|
| 94 | +_deprecated_multi_stage_build_kwargs = { |
| 95 | + "deprecated_in": "0.5.0", |
| 96 | + "removed_in": "0.6.0", |
| 97 | + "current_version": metadata.version("pytest_container"), |
| 98 | + "details": "use MultiStageContainer instead", |
| 99 | +} |
| 100 | + |
| 101 | + |
86 | 102 | @dataclass |
87 | 103 | class MultiStageBuild: |
88 | 104 | """Helper class to perform multi-stage container builds using the |
@@ -165,6 +181,7 @@ def containerfile(self) -> str: |
165 | 181 | } |
166 | 182 | ) |
167 | 183 |
|
| 184 | + @deprecated(**_deprecated_multi_stage_build_kwargs) # type: ignore |
168 | 185 | def prepare_build( |
169 | 186 | self, |
170 | 187 | tmp_path: Path, |
@@ -197,6 +214,7 @@ def prepare_build( |
197 | 214 | containerfile.write(self.containerfile) |
198 | 215 |
|
199 | 216 | @staticmethod |
| 217 | + @deprecated(**_deprecated_multi_stage_build_kwargs) # type: ignore |
200 | 218 | def run_build_step( |
201 | 219 | tmp_path: Path, |
202 | 220 | runtime: OciRuntimeBase, |
@@ -233,6 +251,7 @@ def run_build_step( |
233 | 251 | check_output(cmd) |
234 | 252 | return runtime.get_image_id_from_iidfile(iidfile) |
235 | 253 |
|
| 254 | + @deprecated(**_deprecated_multi_stage_build_kwargs) # type: ignore |
236 | 255 | def build( |
237 | 256 | self, |
238 | 257 | tmp_path: Path, |
@@ -278,6 +297,9 @@ def build( |
278 | 297 | root, |
279 | 298 | extra_build_args, |
280 | 299 | ) |
281 | | - return MultiStageBuild.run_build_step( |
282 | | - tmp_path, runtime, target, extra_build_args |
| 300 | + return cast( |
| 301 | + str, |
| 302 | + MultiStageBuild.run_build_step( |
| 303 | + tmp_path, runtime, target, extra_build_args |
| 304 | + ), |
283 | 305 | ) |
0 commit comments