Repository: conda/conda-build

Issue:
Downstream tests download to wrong subdir (breaks boa+libsolv>=0.7.23)
### What happened?

See https://github.com/conda/conda-index/issues/89 and linked issues.

> This comes from https://github.com/openSUSE/libsolv/commit/cc2da2e789f651b2d0d55fe31c258426bf9e984d#diff-2f0af950e6d2249e0340147b80f5b8194de5362f23026ff65cdb65dfa57696aaR314-R320 , i.e., a newly added strict check in `libsolv=0.7.23` update.
That check is probably reasonable/good -- but `conda-build` is not so strict and dumps the to-be-downstream-tested packages in the current subdir.

In https://github.com/conda-forge/conda-feedstock/pull/197#issuecomment-1400851029 the `noarch` package `conda-smithy` gets downloaded to `conda-build/linux-64` which is then indexed and thus results in a `repodata.json` for `linux-64` with a `noarch` package.

----

I didn't dig deep enough, but I guess somewhere around
https://github.com/conda/conda-build/blob/3.23.3/conda_build/build.py#L3144
-> https://github.com/conda/conda-build/blob/3.23.3/conda_build/render.py#L311
is the culprit.


Discussion:
Until this bug is fixed, https://github.com/conda-forge/boa-feedstock/pull/61 should act as a workaround.
conda-build intentionally combines noarch and native arch packages in an index here https://github.com/conda/conda-build/blob/bd49d736019d3450d99aca21fd46f9e1b959a2a4/conda_build/index.py#L164-L165
It looks like this is unrelated to `libsolv` but is rather some other change in `mamba` that started to check whether the package's `subdir` matches that of the `repodata.json`'s `subdir` (I haven't pinpointed the exact change).

Conda-build rearchives/copies the downstream test's package from the package chache into the `$CONDA_PREFIX/conda-bld` index and uses the host `subdir`. I believe it happens in this hack (see line 220):

https://github.com/conda/conda-build/blob/44defeda1c4cf252a42c07dbd813a03bcc500a51/conda_build/render.py#L202-L223

See #4763 for a potential fix
I now understand that the `subdir` checks on `repodata.json` was added to `libsolv` (not `mamba`). Either way, the investigations done above and the [potential fix](https://github.com/conda/conda-build/pull/4763) is valid.
@kenodegard Should we close this here, or move the ticket to the conda/conda repo?
Closing as I think this was fixed in https://github.com/conda/conda-build/pull/4763
Looks like we missed a second spot where the subdir is incorrectly set, this causes downstream tests to fail:

https://github.com/conda/conda-build/blob/424b736079f0c0317f5f5e47940555866d74ee6c/conda_build/build.py#L2458-L2459

Resolving patch:
diff --git a/conda_build/build.py b/conda_build/build.py
--- a/conda_build/build.py
+++ b/conda_build/build.py
@@ -3006,8 +3006,7 @@ def _construct_metadata_for_test_from_package(package, config):
     with open(os.path.join(info_dir, "index.json")) as f:
         package_data = json.load(f)
 
-    if package_data["subdir"] != "noarch":
-        config.host_subdir = package_data["subdir"]
+    config.host_subdir = package_data["subdir"]
     # We may be testing an (old) package built without filename hashing.
     hash_input = os.path.join(info_dir, "hash_input.json")
     if os.path.isfile(hash_input):


Test patch: