diff --git a/conda_build/build.py b/conda_build/build.py index 9bce326305..b759f84967 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -2886,6 +2886,15 @@ def warn_on_use_of_SRC_DIR(metadata): ) +@deprecated( + "3.16.0", + "24.7.0", + addendum=( + "Test built packages instead, not recipes " + "(e.g., `conda build --test package` instead of `conda build --test recipe/`)." + ), + deprecation_type=FutureWarning, # we need to warn users, not developers +) def _construct_metadata_for_test_from_recipe(recipe_dir, config): config.need_cleanup = False config.recipe_dir = None @@ -2893,11 +2902,6 @@ def _construct_metadata_for_test_from_recipe(recipe_dir, config): metadata = expand_outputs( render_recipe(recipe_dir, config=config, reset_build_id=False) )[0][1] - log = utils.get_logger(__name__) - log.warning( - "Testing based on recipes is deprecated as of conda-build 3.16.0. Please adjust " - "your code to pass your desired conda package to test instead." - ) utils.rm_rf(metadata.config.test_dir) diff --git a/conda_build/deprecations.py b/conda_build/deprecations.py index f691b5192d..cf87b4f25c 100644 --- a/conda_build/deprecations.py +++ b/conda_build/deprecations.py @@ -86,6 +86,7 @@ def __call__( *, addendum: str | None = None, stack: int = 0, + deprecation_type: type[Warning] = DeprecationWarning, ) -> Callable[[Callable[P, T]], Callable[P, T]]: """Deprecation decorator for functions, methods, & classes. @@ -102,6 +103,7 @@ def deprecated_decorator(func: Callable[P, T]) -> Callable[P, T]: remove_in=remove_in, prefix=f"{func.__module__}.{func.__qualname__}", addendum=addendum, + deprecation_type=deprecation_type, ) # alert developer that it's time to remove something @@ -128,6 +130,7 @@ def argument( rename: str | None = None, addendum: str | None = None, stack: int = 0, + deprecation_type: type[Warning] = DeprecationWarning, ) -> Callable[[Callable[P, T]], Callable[P, T]]: """Deprecation decorator for keyword arguments. @@ -149,6 +152,7 @@ def deprecated_decorator(func: Callable[P, T]) -> Callable[P, T]: addendum=( f"Use '{rename}' instead." if rename and not addendum else addendum ), + deprecation_type=deprecation_type, ) # alert developer that it's time to remove something @@ -181,6 +185,7 @@ def action( *, addendum: str | None = None, stack: int = 0, + deprecation_type: type[Warning] = FutureWarning, ) -> ActionType: """Wraps any argparse.Action to issue a deprecation warning.""" @@ -203,7 +208,7 @@ def __init__(inner_self: Self, *args: Any, **kwargs: Any) -> None: else f"`{inner_self.dest}`" ), addendum=addendum, - deprecation_type=FutureWarning, + deprecation_type=deprecation_type, ) # alert developer that it's time to remove something @@ -263,6 +268,7 @@ def constant( *, addendum: str | None = None, stack: int = 0, + deprecation_type: type[Warning] = DeprecationWarning, ) -> None: """Deprecation function for module constant/global. @@ -281,6 +287,7 @@ def constant( remove_in=remove_in, prefix=f"{fullname}.{constant}", addendum=addendum, + deprecation_type=deprecation_type, ) # alert developer that it's time to remove something @@ -310,6 +317,7 @@ def topic( topic: str, addendum: str | None = None, stack: int = 0, + deprecation_type: type[Warning] = DeprecationWarning, ) -> None: """Deprecation function for a topic. @@ -325,6 +333,7 @@ def topic( remove_in=remove_in, prefix=topic, addendum=addendum, + deprecation_type=deprecation_type, ) # alert developer that it's time to remove something @@ -379,7 +388,7 @@ def _generate_message( prefix: str, addendum: str | None, *, - deprecation_type: type[Warning] = DeprecationWarning, + deprecation_type: type[Warning], ) -> tuple[type[Warning] | None, str]: """Generate the standardized deprecation message and determine whether the deprecation is pending, active, or past. diff --git a/news/3192-deprecate-testing-recipes b/news/3192-deprecate-testing-recipes new file mode 100644 index 0000000000..1ea0d425ad --- /dev/null +++ b/news/3192-deprecate-testing-recipes @@ -0,0 +1,19 @@ +### Enhancements + +* + +### Bug fixes + +* + +### Deprecations + +* Mark `conda_build.build._construct_metadata_for_test_from_recipe` as deprecated. Test built packages instead, not recipes (e.g., `conda build --test package` instead of `conda build --test recipe/`). (#3192 via #5352) + +### Docs + +* + +### Other + +* diff --git a/tests/test_build.py b/tests/test_build.py index f7c3f2ba8c..d94df2dd93 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -20,7 +20,10 @@ from conda_build import api, build from conda_build.exceptions import CondaBuildUserError -from .utils import get_noarch_python_meta, metadata_dir +from .utils import get_noarch_python_meta, metadata_dir, metadata_path + +if TYPE_CHECKING: + from conda_build.config import Config if TYPE_CHECKING: from pytest_mock import MockerFixture @@ -351,6 +354,14 @@ def test_copy_readme(testing_metadata: MetaData, readme: str): assert Path(testing_metadata.config.info_dir, readme).exists() +def test_construct_metadata_for_test_from_recipe(testing_config: Config) -> None: + with pytest.warns(FutureWarning): + build._construct_metadata_for_test_from_recipe( + str(metadata_path / "test_source_files"), + testing_config, + ) + + @pytest.mark.skipif(not on_win, reason="WSL is only on Windows") def test_wsl_unsupported( testing_metadata: MetaData,