Skip to content

Commit

Permalink
Make sure the solver sees the correct subdir (#5350)
Browse files Browse the repository at this point in the history
* Re-export subdir
* Ignore subdir = noarch

---------

Co-authored-by: mbargull <[email protected]>
Co-authored-by: Isuru Fernando <[email protected]>
  • Loading branch information
3 people authored Jun 4, 2024
1 parent 01b47f4 commit 17c8fe6
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 1 deletion.
8 changes: 7 additions & 1 deletion conda_build/environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,8 @@ def get_install_actions(
with utils.LoggingContext(conda_log_level):
with capture():
try:
precs = _install_actions(prefix, index, specs)["LINK"]
_actions = _install_actions(prefix, index, specs, subdir=subdir)
precs = _actions["LINK"]
except (NoPackagesFoundError, UnsatisfiableError) as exc:
raise DependencyNeedsBuildingError(exc, subdir=subdir)
except (
Expand Down Expand Up @@ -1256,14 +1257,19 @@ def install_actions(
prefix: str | os.PathLike | Path,
index,
specs: Iterable[str | MatchSpec],
subdir: str | None = None,
) -> InstallActionsType:
# This is copied over from https://github.com/conda/conda/blob/23.11.0/conda/plan.py#L471
# but reduced to only the functionality actually used within conda-build.
subdir_kwargs = {}
if subdir not in (None, "", "noarch"):
subdir_kwargs["CONDA_SUBDIR"] = subdir

with env_vars(
{
"CONDA_ALLOW_NON_CHANNEL_URLS": "true",
"CONDA_SOLVER_IGNORE_TIMESTAMPS": "false",
**subdir_kwargs,
},
callback=reset_context,
):
Expand Down
19 changes: 19 additions & 0 deletions news/5350-subdir-cross
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* Ensure cross-building recipes select the correct noarch package variants. (#5341 via #5350)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target_platform:
- win-64
18 changes: 18 additions & 0 deletions tests/test-recipes/metadata/_cross_unix_windows_mingw/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package:
name: foo
version: 0.0.1

build:
number: 0
script:
- echo 'hello'
- ls $PREFIX
# this is the unix layout.
- test ! -d $PREFIX/x86_64-w64-mingw32
- test -d $PREFIX/Library

requirements:
build:
host:
- m2w64-sysroot_win-64
run:
9 changes: 9 additions & 0 deletions tests/test_api_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1978,6 +1978,15 @@ def test_add_pip_as_python_dependency_from_condarc_file(
api.build(testing_metadata)


@pytest.mark.skipif(on_win, reason="Tests cross-compilation targeting Windows")
def test_cross_unix_windows_mingw(testing_config):
recipe = os.path.join(metadata_dir, "_cross_unix_windows_mingw")
testing_config.channel_urls = [
"conda-forge",
]
api.build(recipe, config=testing_config)


@pytest.mark.parametrize(
"recipe", sorted(Path(metadata_dir, "_build_script_errors").glob("*"))
)
Expand Down

0 comments on commit 17c8fe6

Please sign in to comment.