Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update conda build --test recipe/ deprecation #5352

Merged
merged 5 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2886,18 +2886,22 @@ 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
hash_input = {}
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)

Expand Down
13 changes: 11 additions & 2 deletions conda_build/deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand All @@ -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.

Expand All @@ -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
Expand Down Expand Up @@ -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."""

Expand All @@ -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
Expand Down Expand Up @@ -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.

Expand All @@ -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
Expand Down Expand Up @@ -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.

Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
19 changes: 19 additions & 0 deletions news/3192-deprecate-testing-recipes
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* <news item>

### 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

* <news item>

### Other

* <news item>
13 changes: 12 additions & 1 deletion tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Loading