Skip to content

Commit

Permalink
Merge branch 'main' into fix/undefined-env-vars
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Jun 11, 2024
2 parents 6722429 + 3515dbe commit 4a0ffd9
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 13 deletions.
19 changes: 11 additions & 8 deletions conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(" ")

Expand Down Expand Up @@ -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}")
Expand Down
2 changes: 1 addition & 1 deletion conda_build/inspect_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
8 changes: 5 additions & 3 deletions conda_build/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = ""
Expand Down
2 changes: 1 addition & 1 deletion conda_build/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
24 changes: 24 additions & 0 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
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

from .utils import get_noarch_python_meta, metadata_dir

if TYPE_CHECKING:
from pytest_mock import MockerFixture

from conda_build.metadata import MetaData


Expand Down Expand Up @@ -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={},
)

0 comments on commit 4a0ffd9

Please sign in to comment.