From 5d8444b2114e621839eb276f6a2b9266117fb9fa Mon Sep 17 00:00:00 2001 From: Ken Odegard Date: Fri, 19 Apr 2024 16:35:30 +0200 Subject: [PATCH] Deprecate `noarch_python_build_age` (#5298) --- conda_build/config.py | 8 +------- conda_build/render.py | 34 ++++++++++------------------------ tests/conftest.py | 3 --- 3 files changed, 11 insertions(+), 34 deletions(-) diff --git a/conda_build/config.py b/conda_build/config.py index 1949fbc071..09ce6b0718 100644 --- a/conda_build/config.py +++ b/conda_build/config.py @@ -54,7 +54,7 @@ def set_invocation_time(): _src_cache_root_default = None error_overlinking_default = "false" error_overdepending_default = "false" -noarch_python_build_age_default = 0 +deprecated.constant("24.5", "24.7", "noarch_python_build_age_default", 0) enable_static_default = "false" no_rewrite_stdout_env_default = "false" ignore_verify_codes_default = [] @@ -157,12 +157,6 @@ def _get_default_settings(): ).lower() == "true", ), - Setting( - "noarch_python_build_age", - context.conda_build.get( - "noarch_python_build_age", noarch_python_build_age_default - ), - ), Setting( "enable_static", context.conda_build.get("enable_static", enable_static_default).lower() diff --git a/conda_build/render.py b/conda_build/render.py index 9bbdcc6efa..b021f8a5b6 100644 --- a/conda_build/render.py +++ b/conda_build/render.py @@ -795,11 +795,11 @@ def reparse(metadata): def distribute_variants( - metadata, + metadata: MetaData, variants, - permit_unsatisfiable_variants=False, - allow_no_other_outputs=False, - bypass_env_check=False, + permit_unsatisfiable_variants: bool = False, + allow_no_other_outputs: bool = False, + bypass_env_check: bool = False, ) -> list[MetaDataTuple]: rendered_metadata: dict[ tuple[str, str, tuple[tuple[str, str], ...]], MetaDataTuple @@ -810,27 +810,13 @@ def distribute_variants( # which python version we prefer. `python_age` can use used to tweak which # python gets used here. if metadata.noarch or metadata.noarch_python: - age = int( - metadata.get_value( - "build/noarch_python_build_age", metadata.config.noarch_python_build_age - ) - ) - versions = [] - for variant in variants: - if "python" in variant: - vo = variant["python"] - if vo not in versions: - versions.append(vo) - version_indices = sorted( - range(len(versions)), key=lambda k: VersionOrder(versions[k].split(" ")[0]) - ) - if age < 0: - age = 0 - elif age > len(versions) - 1: - age = len(versions) - 1 - build_ver = versions[version_indices[len(versions) - 1 - age]] + # filter variants by the newest Python version + version = sorted( + {version for variant in variants if (version := variant.get("python"))}, + key=lambda key: VersionOrder(key.split(" ")[0]), + )[-1] variants = filter_by_key_value( - variants, "python", build_ver, "noarch_python_reduction" + variants, "python", version, "noarch_python_reduction" ) # store these for reference later diff --git a/tests/conftest.py b/tests/conftest.py index 7dc0ae021c..465cab6fcc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -27,7 +27,6 @@ filename_hashing_default, ignore_verify_codes_default, no_rewrite_stdout_env_default, - noarch_python_build_age_default, ) from conda_build.metadata import MetaData from conda_build.utils import check_call_env, copy_into, prepend_bin_path @@ -100,7 +99,6 @@ def boolify(v): _src_cache_root=_src_cache_root_default, error_overlinking=boolify(error_overlinking_default), error_overdepending=boolify(error_overdepending_default), - noarch_python_build_age=noarch_python_build_age_default, enable_static=boolify(enable_static_default), no_rewrite_stdout_env=boolify(no_rewrite_stdout_env_default), ignore_verify_codes=ignore_verify_codes_default, @@ -112,7 +110,6 @@ def boolify(v): assert result.no_rewrite_stdout_env is False assert result._src_cache_root is None assert result.src_cache_root == testing_workdir - assert result.noarch_python_build_age == 0 return result