diff --git a/conda_build/build.py b/conda_build/build.py index 184f3cf79e..3fa97fb0a3 100644 --- a/conda_build/build.py +++ b/conda_build/build.py @@ -1753,13 +1753,16 @@ def bundle_conda( output["script"], args[0], ) - if "system32" in args[0] and "bash" in args[0]: - print( - "ERROR :: WSL bash.exe detected, this will not work (PRs welcome!). Please\n" - " use MSYS2 packages. Add `m2-base` and more (depending on what your" - " script needs) to `requirements/build` instead." + if ( + # WSL bash is always the same path, it is an alias to the default + # distribution as configured by the user + on_win and Path("C:\\Windows\\System32\\bash.exe").samefile(args[0]) + ): + raise CondaBuildUserError( + "WSL bash.exe is not supported. Please use MSYS2 packages. Add " + "`m2-base` and more (depending on what your script needs) to " + "`requirements/build` instead." ) - sys.exit(1) else: args = interpreter.split(" ") @@ -4072,11 +4075,11 @@ def handle_pypi_upload(wheels, config): try: utils.check_call_env(args + [f]) except: - utils.get_logger(__name__).warn( + utils.get_logger(__name__).warning( "wheel upload failed - is twine installed?" " Is this package registered?" ) - utils.get_logger(__name__).warn(f"Wheel file left in {f}") + utils.get_logger(__name__).warning(f"Wheel file left in {f}") else: print(f"anaconda_upload is not set. Not uploading wheels: {wheels}") diff --git a/conda_build/inspect_pkg.py b/conda_build/inspect_pkg.py index 43fc401551..5747f3a7b8 100644 --- a/conda_build/inspect_pkg.py +++ b/conda_build/inspect_pkg.py @@ -258,7 +258,7 @@ def inspect_linkages( if relative: precs = list(which_package(relative, prefix)) if len(precs) > 1: - get_logger(__name__).warn( + get_logger(__name__).warning( "Warning: %s comes from multiple packages: %s", path, comma_join(map(str, precs)), diff --git a/conda_build/metadata.py b/conda_build/metadata.py index d41e81a6db..d3ee86f214 100644 --- a/conda_build/metadata.py +++ b/conda_build/metadata.py @@ -199,7 +199,7 @@ def get_selectors(config: Config) -> dict[str, bool]: if not np: np = defaults["numpy"] if config.verbose: - utils.get_logger(__name__).warn( + utils.get_logger(__name__).warning( "No numpy version specified in conda_build_config.yaml. " "Falling back to default numpy value of {}".format(defaults["numpy"]) ) @@ -995,7 +995,9 @@ def _toposort_outputs(output_tuples: list[OutputTuple]) -> list[OutputTuple]: non_conda_outputs.append(output_tuple) else: # TODO: is it even possible to get here? and if so should we silently ignore or error? - utils.get_logger(__name__).warn("Found an output without a name, skipping") + utils.get_logger(__name__).warning( + "Found an output without a name, skipping" + ) # Iterate over conda packages, creating a mapping of package names to their # dependencies to be used in toposort @@ -2326,7 +2328,7 @@ def extract_single_output_text( output = output_matches[output_index] if output_matches else "" except ValueError: if not self.path and self.meta.get("extra", {}).get("parent_recipe"): - utils.get_logger(__name__).warn( + utils.get_logger(__name__).warning( f"Didn't match any output in raw metadata. Target value was: {output_name}" ) output = "" diff --git a/conda_build/utils.py b/conda_build/utils.py index 17d1c1f031..e5e8d9c8c2 100644 --- a/conda_build/utils.py +++ b/conda_build/utils.py @@ -1318,7 +1318,7 @@ def find_recipe(path: str) -> str: metas = [m for m in VALID_METAS if os.path.isfile(os.path.join(path, m))] if len(metas) == 1: - get_logger(__name__).warn( + get_logger(__name__).warning( "Multiple meta files found. " f"The {metas[0]} file in the base directory ({path}) " "will be used." diff --git a/tests/test_build.py b/tests/test_build.py index af5abb0f70..f1a9f11736 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -15,6 +15,7 @@ from typing import TYPE_CHECKING import pytest +from conda.common.compat import on_win from conda_build import api, build from conda_build.exceptions import CondaBuildUserError @@ -22,6 +23,8 @@ from .utils import get_noarch_python_meta, metadata_dir if TYPE_CHECKING: + from pytest_mock import MockerFixture + from conda_build.metadata import MetaData @@ -345,3 +348,24 @@ def test_copy_readme(testing_metadata: MetaData, readme: str): Path(testing_metadata.config.work_dir, readme).touch() build.copy_readme(testing_metadata) assert Path(testing_metadata.config.info_dir, readme).exists() + + +@pytest.mark.skipif(not on_win, reason="WSL is only on Windows") +def test_wsl_unsupported( + testing_metadata: MetaData, + mocker: MockerFixture, + tmp_path: Path, +): + mocker.patch( + "conda_build.os_utils.external.find_executable", + return_value="C:\\Windows\\System32\\bash.exe", + ) + + (script := tmp_path / "install.sh").touch() + with pytest.raises(CondaBuildUserError): + build.bundle_conda( + output={"script": script}, + metadata=testing_metadata, + env={}, + stats={}, + )