Repository: conda-forge/conda-smithy

Issue:
Consider virtual packages for noarch build environment
<!--
Thanks for reporting your issue.
Please fill out the sections below.
-->

- [x] I read [the conda-forge documentation](https://conda-forge.org/docs/user/introduction.html#how-can-i-install-packages-from-conda-forge) and could not find the solution for my problem there.

Issue:

Currently, all `noarch: python` packages are [built on Linux](https://conda-forge.org/docs/maintainer/knowledge_base.html#noarch-python), since they do not require a specific OS. This is not the case anymore with the introduction of the `__unix` and `__win` [virtual packages](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-virtual.html).
Here, a package could only be available on win (Through declaring a `__win` dependency) but still be `noarch` which would make this package not buildable. 
It would be helpful if smithy would be able to take this into account when selecting the environment it uses for building. The easiest way would probably be using one of the environments from staged-recipes since they're already used for initial testing.


Discussion:

Resolving patch:
diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py
--- a/conda_smithy/configure_feedstock.py
+++ b/conda_smithy/configure_feedstock.py
@@ -1008,7 +1008,7 @@ def _get_platforms_of_provider(provider, forge_config):
         if provider in providers:
             platforms.append(platform)
             archs.append(arch)
-            if platform == "linux" and arch == "64":
+            if platform_arch in forge_config["noarch_platforms"]:
                 keep_noarchs.append(True)
             else:
                 keep_noarchs.append(False)
@@ -1024,7 +1024,7 @@ def _get_platforms_of_provider(provider, forge_config):
         ):
             platforms.append(platform)
             archs.append(arch)
-            if platform == "linux" and arch == "64":
+            if platform_arch in forge_config["noarch_platforms"]:
                 keep_noarchs.append(True)
             else:
                 keep_noarchs.append(False)
@@ -1722,6 +1722,7 @@ def _load_forge_config(forge_dir, exclusive_config_file, forge_yml=None):
             "osx": None,
             "win": None,
         },
+        # value is the build_platform, key is the target_platform
         "build_platform": {
             "linux_64": "linux_64",
             "linux_aarch64": "linux_aarch64",
@@ -1731,6 +1732,7 @@ def _load_forge_config(forge_dir, exclusive_config_file, forge_yml=None):
             "win_64": "win_64",
             "osx_64": "osx_64",
         },
+        "noarch_platforms": ["linux_64"],
         "os_version": {
             "linux_64": None,
             "linux_aarch64": None,
@@ -1842,11 +1844,24 @@ def _load_forge_config(forge_dir, exclusive_config_file, forge_yml=None):
             )
         )
 
-    for platform_arch in config["build_platform"].keys():
+    target_platforms = sorted(config["build_platform"].keys())
+
+    for platform_arch in target_platforms:
         config[platform_arch] = {"enabled": "True"}
         if platform_arch not in config["provider"]:
             config["provider"][platform_arch] = None
 
+    config["noarch_platforms"] = conda_build.utils.ensure_list(
+        config["noarch_platforms"]
+    )
+
+    for noarch_platform in sorted(config["noarch_platforms"]):
+        if noarch_platform not in target_platforms:
+            raise ValueError(
+                f"Unknown noarch platform {noarch_platform}. Expected one of: "
+                f"{target_platforms}"
+            )
+
     config["secrets"] = sorted(set(config["secrets"] + ["BINSTAR_TOKEN"]))
 
     if config["test_on_native_only"]:


Test patch:
diff --git a/tests/test_configure_feedstock.py b/tests/test_configure_feedstock.py
--- a/tests/test_configure_feedstock.py
+++ b/tests/test_configure_feedstock.py
@@ -758,6 +758,23 @@ def test_conda_forge_yaml_empty(config_yaml):
     ]
 
 
+def test_noarch_platforms_bad_yaml(config_yaml):
+    load_forge_config = lambda: cnfgr_fdstk._load_forge_config(  # noqa
+        config_yaml,
+        exclusive_config_file=os.path.join(
+            config_yaml, "recipe", "default_config.yaml"
+        ),
+    )
+
+    with open(os.path.join(config_yaml, "conda-forge.yml"), "a+") as fp:
+        fp.write("noarch_platforms: [eniac, zx80]")
+
+    with pytest.raises(ValueError) as excinfo:
+        load_forge_config()
+
+    assert "eniac" in str(excinfo.value)
+
+
 def test_forge_yml_alt_path(config_yaml):
     load_forge_config = (
         lambda forge_yml: cnfgr_fdstk._load_forge_config(  # noqa