From 695a4e9d865619b227bfebc2071113a9b13a2e4e Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 21 May 2024 15:57:42 +0200 Subject: [PATCH 1/7] re-export subdir Co-authored-by: mbargull --- conda_build/environ.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/conda_build/environ.py b/conda_build/environ.py index 7a3a7ca8cb..2606002de4 100644 --- a/conda_build/environ.py +++ b/conda_build/environ.py @@ -888,7 +888,7 @@ def get_install_actions( with utils.LoggingContext(conda_log_level): with capture(): try: - precs = _install_actions(prefix, index, specs)["LINK"] + precs = _install_actions(prefix, index, specs, subdir=subdir)["LINK"] except (NoPackagesFoundError, UnsatisfiableError) as exc: raise DependencyNeedsBuildingError(exc, subdir=subdir) except ( @@ -1256,14 +1256,16 @@ 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 = {"CONDA_SUBDIR": subdir} if subdir else {} with env_vars( { "CONDA_ALLOW_NON_CHANNEL_URLS": "true", "CONDA_SOLVER_IGNORE_TIMESTAMPS": "false", + **subdir_kwargs, }, callback=reset_context, ): From 6924f054507960d406030728949cc1534b13be52 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 21 May 2024 17:52:24 +0200 Subject: [PATCH 2/7] ignore subdir = noarch --- conda_build/environ.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda_build/environ.py b/conda_build/environ.py index 2606002de4..c335e34c5e 100644 --- a/conda_build/environ.py +++ b/conda_build/environ.py @@ -1260,7 +1260,7 @@ def install_actions( ) -> 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 = {"CONDA_SUBDIR": subdir} if subdir else {} + subdir_kwargs = {"CONDA_SUBDIR": subdir} if subdir not in (None, "", "noarch") else {} with env_vars( { "CONDA_ALLOW_NON_CHANNEL_URLS": "true", From 6ec369647e2db55f59fffe0003de2655d5da6a2c Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 21 May 2024 17:54:59 +0200 Subject: [PATCH 3/7] pre-commit --- conda_build/environ.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/conda_build/environ.py b/conda_build/environ.py index c335e34c5e..0dda118901 100644 --- a/conda_build/environ.py +++ b/conda_build/environ.py @@ -888,7 +888,9 @@ def get_install_actions( with utils.LoggingContext(conda_log_level): with capture(): try: - precs = _install_actions(prefix, index, specs, subdir=subdir)["LINK"] + precs = _install_actions(prefix, index, specs, subdir=subdir)[ + "LINK" + ] except (NoPackagesFoundError, UnsatisfiableError) as exc: raise DependencyNeedsBuildingError(exc, subdir=subdir) except ( @@ -1260,7 +1262,10 @@ def install_actions( ) -> 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 = {"CONDA_SUBDIR": subdir} if subdir not in (None, "", "noarch") else {} + subdir_kwargs = {} + if subdir not in (None, "", "noarch"): + subdir_kwargs["CONDA_SUBDIR"] = subdir + with env_vars( { "CONDA_ALLOW_NON_CHANNEL_URLS": "true", From fde7982dd981e52e71e8f3634c5f93a767580d80 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 22 May 2024 11:02:55 +0200 Subject: [PATCH 4/7] add test --- conda_build/environ.py | 5 ++--- .../conda_build_config.yaml | 2 ++ .../_cross_unix_windows_mingw/meta.yaml | 18 ++++++++++++++++++ tests/test_api_build.py | 7 +++++++ 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 tests/test-recipes/metadata/_cross_unix_windows_mingw/conda_build_config.yaml create mode 100644 tests/test-recipes/metadata/_cross_unix_windows_mingw/meta.yaml diff --git a/conda_build/environ.py b/conda_build/environ.py index 0dda118901..0ce38d1668 100644 --- a/conda_build/environ.py +++ b/conda_build/environ.py @@ -888,9 +888,8 @@ def get_install_actions( with utils.LoggingContext(conda_log_level): with capture(): try: - precs = _install_actions(prefix, index, specs, subdir=subdir)[ - "LINK" - ] + _actions = _install_actions(prefix, index, specs, subdir=subdir) + precs = _actions["LINK"] except (NoPackagesFoundError, UnsatisfiableError) as exc: raise DependencyNeedsBuildingError(exc, subdir=subdir) except ( diff --git a/tests/test-recipes/metadata/_cross_unix_windows_mingw/conda_build_config.yaml b/tests/test-recipes/metadata/_cross_unix_windows_mingw/conda_build_config.yaml new file mode 100644 index 0000000000..ad7ed0e836 --- /dev/null +++ b/tests/test-recipes/metadata/_cross_unix_windows_mingw/conda_build_config.yaml @@ -0,0 +1,2 @@ +target_platform: + - win-64 \ No newline at end of file diff --git a/tests/test-recipes/metadata/_cross_unix_windows_mingw/meta.yaml b/tests/test-recipes/metadata/_cross_unix_windows_mingw/meta.yaml new file mode 100644 index 0000000000..c180f95383 --- /dev/null +++ b/tests/test-recipes/metadata/_cross_unix_windows_mingw/meta.yaml @@ -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: diff --git a/tests/test_api_build.py b/tests/test_api_build.py index a663f18e73..ec092addfb 100644 --- a/tests/test_api_build.py +++ b/tests/test_api_build.py @@ -1968,3 +1968,10 @@ def test_add_pip_as_python_dependency_from_condarc_file( with env_var("CONDARC", conda_rc, reset_context): with check_build_fails: 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/label/m2w64-experimental", "conda-forge"] + api.build(recipe, config=testing_config) From 491a36ad1e3e96698326eb94a56697501f7d1620 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 22 May 2024 11:03:12 +0200 Subject: [PATCH 5/7] pre-commit --- tests/test_api_build.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_api_build.py b/tests/test_api_build.py index ec092addfb..7dbc2dfa48 100644 --- a/tests/test_api_build.py +++ b/tests/test_api_build.py @@ -1973,5 +1973,8 @@ def test_add_pip_as_python_dependency_from_condarc_file( @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/label/m2w64-experimental", "conda-forge"] + testing_config.channel_urls = [ + "conda-forge/label/m2w64-experimental", + "conda-forge", + ] api.build(recipe, config=testing_config) From d223f37d72f9794721b97948a08795ac9cbed087 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 23 May 2024 10:24:34 +0200 Subject: [PATCH 6/7] Add news --- news/5350-subdir-cross | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 news/5350-subdir-cross diff --git a/news/5350-subdir-cross b/news/5350-subdir-cross new file mode 100644 index 0000000000..66824fb733 --- /dev/null +++ b/news/5350-subdir-cross @@ -0,0 +1,19 @@ +### Enhancements + +* + +### Bug fixes + +* Ensure cross-building recipes select the correct noarch package variants. (#5341 via #5350) + +### Deprecations + +* + +### Docs + +* + +### Other + +* From 9867682dc9e683e4c99b0fb9c5ee45e8451870f5 Mon Sep 17 00:00:00 2001 From: Isuru Fernando Date: Tue, 4 Jun 2024 09:08:19 -0700 Subject: [PATCH 7/7] Remove experimental label --- tests/test_api_build.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_api_build.py b/tests/test_api_build.py index b1537950ea..5296f4e5ab 100644 --- a/tests/test_api_build.py +++ b/tests/test_api_build.py @@ -1975,7 +1975,6 @@ def test_add_pip_as_python_dependency_from_condarc_file( def test_cross_unix_windows_mingw(testing_config): recipe = os.path.join(metadata_dir, "_cross_unix_windows_mingw") testing_config.channel_urls = [ - "conda-forge/label/m2w64-experimental", "conda-forge", ] api.build(recipe, config=testing_config)