Skip to content

Commit c28ba15

Browse files
committed
deprecate MultiStageBuild
1 parent 3734b4a commit c28ba15

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Breaking changes:
66
- change type of ``OciRuntimeBase.build_command`` from ``List[str]`` to
77
``Tuple[str, ...]``
88

9+
- deprecate :py:class:`~pytest_container.build.MultiStageBuild` in favor
10+
:py:class:`~pytest_container.container.MultiStageContainer`
11+
912

1013
Improvements and new features:
1114

pytest_container/build.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
builds via :py:class:`MultiStageBuild`.
44
55
"""
6+
import sys
67
import tempfile
78
from dataclasses import dataclass
89
from os.path import basename
910
from os.path import join
1011
from pathlib import Path
1112
from string import Template
1213
from subprocess import check_output
14+
from typing import cast
1315
from typing import Dict
1416
from typing import List
1517
from typing import Optional
@@ -18,13 +20,19 @@
1820

1921
from _pytest.config import Config
2022
from _pytest.mark.structures import ParameterSet
23+
from deprecation import deprecated
2124
from pytest_container.container import Container
2225
from pytest_container.container import container_and_marks_from_pytest_param
2326
from pytest_container.container import DerivedContainer
2427
from pytest_container.logging import _logger
2528
from pytest_container.runtime import OciRuntimeBase
2629
from pytest_container.runtime import ToParamMixin
2730

31+
if sys.version_info >= (3, 8):
32+
from importlib import metadata
33+
else:
34+
import importlib_metadata as metadata
35+
2836

2937
@dataclass(frozen=True)
3038
class GitRepositoryBuild(ToParamMixin):
@@ -83,6 +91,14 @@ def test_command(self) -> str:
8391
return cd_cmd
8492

8593

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+
86102
@dataclass
87103
class MultiStageBuild:
88104
"""Helper class to perform multi-stage container builds using the
@@ -165,6 +181,7 @@ def containerfile(self) -> str:
165181
}
166182
)
167183

184+
@deprecated(**_deprecated_multi_stage_build_kwargs) # type: ignore
168185
def prepare_build(
169186
self,
170187
tmp_path: Path,
@@ -197,6 +214,7 @@ def prepare_build(
197214
containerfile.write(self.containerfile)
198215

199216
@staticmethod
217+
@deprecated(**_deprecated_multi_stage_build_kwargs) # type: ignore
200218
def run_build_step(
201219
tmp_path: Path,
202220
runtime: OciRuntimeBase,
@@ -233,6 +251,7 @@ def run_build_step(
233251
check_output(cmd)
234252
return runtime.get_image_id_from_iidfile(iidfile)
235253

254+
@deprecated(**_deprecated_multi_stage_build_kwargs) # type: ignore
236255
def build(
237256
self,
238257
tmp_path: Path,
@@ -278,6 +297,9 @@ def build(
278297
root,
279298
extra_build_args,
280299
)
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+
),
283305
)

0 commit comments

Comments
 (0)