diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index 3be1abe88..5d109d488 100644 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -520,6 +520,40 @@ def _collapse_subpackage_variants( "BUILD", } + # on osx, merge MACOSX_DEPLOYMENT_TARGET & c_stdlib_version to max of either; see #1884 + if squished_used_variants["target_platform"][0].startswith("osx"): + # in global pinning, but use fallback to avoid having to set it in all tests + v_stdlib = squished_used_variants.get("c_stdlib_version", ["0.0"]) + # also in global pinning, but prepare for eventual disappearance + macdt = squished_used_variants.get("MACOSX_DEPLOYMENT_TARGET", [None]) + # the merge logic only deals with one version + if (len(v_stdlib) > 1 and macdt[0] is not None) or len(macdt) > 1: + raise ValueError( + "Not prepared to deal with multiple c_stdlib_version that do not match " + "MACOSX_DEPLOYMENT_TARGET! Please delete MACOSX_DEPLOYMENT_TARGET and " + "set only c_stdlib_version in conda_build_config.yaml!" + ) + # now that we ruled out multiple values, extract the single value + v_stdlib = v_stdlib[0] + macdt = macdt[0] + if macdt is not None and v_stdlib != macdt: + logger.warn( + "Duplicate specification of macosx deployment target!\n" + "If your conda_build_config.yaml sets `MACOSX_DEPLOYMENT_TARGET`, " + "please change the name of that key to `c_stdlib_version`!" + ) + # determine maximum version and use it to populate both + cond = VersionOrder(v_stdlib) > VersionOrder(macdt) + new_val = v_stdlib if cond else macdt + squished_used_variants["c_stdlib_version"] = [new_val] + + # in any case, we set MACOSX_DEPLOYMENT_TARGET to match c_stdlib_version + # (if it is set), for ease of use in conda-forge-ci-setup + if "c_stdlib_version" in squished_used_variants: + squished_used_variants["MACOSX_DEPLOYMENT_TARGET"] = ( + squished_used_variants["c_stdlib_version"] + ) + if not is_noarch: always_keep_keys.add("target_platform") diff --git a/news/1889-merge-c_stdlib_version-and-MACOSX_DEPLOYMENT_TARGET-on-osx.rst b/news/1889-merge-c_stdlib_version-and-MACOSX_DEPLOYMENT_TARGET-on-osx.rst new file mode 100644 index 000000000..b0b71f828 --- /dev/null +++ b/news/1889-merge-c_stdlib_version-and-MACOSX_DEPLOYMENT_TARGET-on-osx.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* Ensure we populate MACOSX_DEPLOYMENT_TARGET for use in conda-forge-ci-setup also when using `c_stdlib_version` (#1884 via #1889) + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/tests/conftest.py b/tests/conftest.py index 8125265e9..d1f1f326c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -241,6 +241,30 @@ def stdlib_recipe(config_yaml, request): ) +@pytest.fixture(scope="function") +def stdlib_deployment_target_recipe(config_yaml, stdlib_recipe): + # append to existing stdlib_config.yaml from stdlib_recipe + with open( + os.path.join(config_yaml, "recipe", "stdlib_config.yaml"), "a" + ) as f: + f.write( + """\ +MACOSX_DEPLOYMENT_TARGET: # [osx] + - 10.14 # [osx and x86_64] + - 12.0 # [osx and arm64] +""" + ) + return RecipeConfigPair( + str(config_yaml), + _load_forge_config( + config_yaml, + exclusive_config_file=os.path.join( + config_yaml, "recipe", "stdlib_config.yaml" + ), + ), + ) + + @pytest.fixture(scope="function") def upload_on_branch_recipe(config_yaml, request): with open(os.path.join(config_yaml, "recipe", "meta.yaml"), "w") as fh: diff --git a/tests/test_configure_feedstock.py b/tests/test_configure_feedstock.py index 2267b236c..98404f79a 100644 --- a/tests/test_configure_feedstock.py +++ b/tests/test_configure_feedstock.py @@ -246,6 +246,32 @@ def test_stdlib_on_azure(stdlib_recipe, jinja_env): # no stdlib-version expected on windows +def test_stdlib_deployment_target( + stdlib_deployment_target_recipe, jinja_env, caplog +): + with caplog.at_level(logging.WARNING): + configure_feedstock.render_azure( + jinja_env=jinja_env, + forge_config=stdlib_deployment_target_recipe.config, + forge_dir=stdlib_deployment_target_recipe.recipe, + ) + # this configuration should be run + assert stdlib_deployment_target_recipe.config["azure"]["enabled"] + matrix_dir = os.path.join( + stdlib_deployment_target_recipe.recipe, ".ci_support" + ) + assert os.path.isdir(matrix_dir) + with open(os.path.join(matrix_dir, "osx_64_.yaml")) as f: + lines = f.readlines() + content = "".join(lines) + # ensure both MACOSX_DEPLOYMENT_TARGET and c_stdlib_version match + # the maximum of either, c.f. stdlib_deployment_target_recipe fixture + assert bool(re.match(r"(?s).*c_stdlib_version:\s*- ['\"]?10\.14", content)) + assert bool( + re.match(r"(?s).*MACOSX_DEPLOYMENT_TARGET:\s*- ['\"]?10\.14", content) + ) + + def test_upload_on_branch_azure(upload_on_branch_recipe, jinja_env): configure_feedstock.render_azure( jinja_env=jinja_env,