diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 765c363..c8e6d58 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,9 @@ Breaking changes: - change type of ``OciRuntimeBase.build_command`` from ``List[str]`` to ``Tuple[str, ...]`` +- deprecate :py:class:`~pytest_container.build.MultiStageBuild` in favor + :py:class:`~pytest_container.container.MultiStageContainer` + Improvements and new features: diff --git a/pytest_container/build.py b/pytest_container/build.py index 22d2514..d477e38 100644 --- a/pytest_container/build.py +++ b/pytest_container/build.py @@ -3,6 +3,7 @@ builds via :py:class:`MultiStageBuild`. """ +import sys import tempfile from dataclasses import dataclass from os.path import basename @@ -18,6 +19,7 @@ from _pytest.config import Config from _pytest.mark.structures import ParameterSet +from deprecation import deprecated from pytest_container.container import Container from pytest_container.container import container_and_marks_from_pytest_param from pytest_container.container import DerivedContainer @@ -25,6 +27,11 @@ from pytest_container.runtime import OciRuntimeBase from pytest_container.runtime import ToParamMixin +if sys.version_info >= (3, 8): + from importlib import metadata +else: + import importlib_metadata as metadata + @dataclass(frozen=True) class GitRepositoryBuild(ToParamMixin): @@ -83,6 +90,14 @@ def test_command(self) -> str: return cd_cmd +_deprecated_multi_stage_build_kwargs = { + "deprecated_in": "0.5.0", + "removed_in": "0.6.0", + "current_version": metadata.version("pytest_container"), + "details": "use MultiStageContainer instead", +} + + @dataclass class MultiStageBuild: """Helper class to perform multi-stage container builds using the @@ -149,6 +164,7 @@ class MultiStageBuild: ] @property + @deprecated(**_deprecated_multi_stage_build_kwargs) # type: ignore def containerfile(self) -> str: """The rendered :file:`Containerfile` from the template supplied in :py:attr:`containerfile_template`. @@ -165,6 +181,7 @@ def containerfile(self) -> str: } ) + @deprecated(**_deprecated_multi_stage_build_kwargs) # type: ignore def prepare_build( self, tmp_path: Path, @@ -197,6 +214,7 @@ def prepare_build( containerfile.write(self.containerfile) @staticmethod + @deprecated(**_deprecated_multi_stage_build_kwargs) # type: ignore def run_build_step( tmp_path: Path, runtime: OciRuntimeBase, @@ -233,6 +251,7 @@ def run_build_step( check_output(cmd) return runtime.get_image_id_from_iidfile(iidfile) + @deprecated(**_deprecated_multi_stage_build_kwargs) # type: ignore def build( self, tmp_path: Path,