diff --git a/conda_build/build.py b/conda_build/build.py index 3f7dc0470a..25b64c30ff 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -3977,7 +3977,10 @@ def build_tree( return list(built_packages.keys()) -def handle_anaconda_upload(paths, config): +def handle_anaconda_upload( + paths: Iterable[str | os.PathLike | Path], + config: Config, +) -> None: from .os_utils.external import find_executable paths = utils.ensure_list(paths) @@ -4011,7 +4014,7 @@ def handle_anaconda_upload(paths, config): "# To have conda build upload to anaconda.org automatically, use\n" f"# {prompter}conda config --set anaconda_upload yes\n" ) - no_upload_message += f"anaconda upload{joiner}" + joiner.join(paths) + no_upload_message += f"anaconda upload{joiner}" + joiner.join(map(str, paths)) if not upload: print(no_upload_message) @@ -4019,7 +4022,7 @@ def handle_anaconda_upload(paths, config): if not anaconda: print(no_upload_message) - sys.exit( + raise CondaBuildUserError( "Error: cannot locate anaconda command (required for upload)\n" "# Try:\n" f"# {prompter}conda install anaconda-client" diff --git a/tests/test_build.py b/tests/test_build.py index f1a9f11736..4078d8273e 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -25,6 +25,7 @@ if TYPE_CHECKING: from pytest_mock import MockerFixture + from conda_build.config import Config from conda_build.metadata import MetaData @@ -369,3 +370,14 @@ def test_wsl_unsupported( env={}, stats={}, ) + + +def test_handle_anaconda_upload(testing_config: Config, mocker: MockerFixture): + mocker.patch( + "conda_build.os_utils.external.find_executable", + return_value=None, + ) + testing_config.anaconda_upload = True + + with pytest.raises(CondaBuildUserError): + build.handle_anaconda_upload((), testing_config)