diff --git a/conda_smithy/cli.py b/conda_smithy/cli.py index bbc0a1a37..537fb857d 100644 --- a/conda_smithy/cli.py +++ b/conda_smithy/cli.py @@ -11,7 +11,7 @@ import conda # noqa from conda_build.metadata import MetaData from rattler_build_conda_compat.render import MetaData as RattlerMetaData -from rattler_build_conda_compat.utils import has_recipe as has_recipe_v2 +from rattler_build_conda_compat.utils import has_recipe as has_recipe_v1 from ruamel.yaml import YAML import conda_smithy.cirun_utils @@ -132,7 +132,7 @@ def __call__(self, args): build_tool = CONDA_BUILD # detect what recipe ( meta.yaml or recipe.yaml ) we should render - if has_recipe_v2(args.recipe_directory): + if has_recipe_v1(args.recipe_directory): build_tool = RATTLER_BUILD if build_tool == CONDA_BUILD: diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index 276edee49..abafcabd0 100644 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -962,7 +962,7 @@ def _render_ci_provider( if ver: os.environ["DEFAULT_LINUX_VERSION"] = ver - # detect if it's rattler-build recipe + # detect if it's v1 recipe if forge_config["conda_build_tool"] == RATTLER_BUILD: recipe_file = "recipe.yaml" else: @@ -997,7 +997,7 @@ def _render_ci_provider( ) # If we are using new recipe - # we also load rattler-build variants.yaml + # we also load v1 variants.yaml if recipe_file == "recipe.yaml": # get_selectors from conda-build return namespace # so it is usefull to reuse it here diff --git a/conda_smithy/lint_recipe.py b/conda_smithy/lint_recipe.py index ffdbfca56..564cef7ed 100644 --- a/conda_smithy/lint_recipe.py +++ b/conda_smithy/lint_recipe.py @@ -12,7 +12,7 @@ import jsonschema import requests -from conda_smithy.linter import conda_recipe_v2_linter +from conda_smithy.linter import conda_recipe_v1_linter from conda_smithy.linter.hints import ( hint_check_spdx, hint_pip_usage, @@ -39,7 +39,7 @@ lint_recipe_have_tests, lint_recipe_maintainers, lint_recipe_name, - lint_recipe_v2_noarch_and_runtime_dependencies, + lint_recipe_v1_noarch_and_runtime_dependencies, lint_require_lower_bound_on_python_version, lint_rust_licenses_are_bundled, lint_section_order, @@ -103,7 +103,7 @@ def lintify_meta_yaml( meta, recipe_dir=None, conda_forge=False, - recipe_version: int = 1, + recipe_version: int = 0, ) -> Tuple[List[str], List[str]]: lints = [] hints = [] @@ -111,7 +111,7 @@ def lintify_meta_yaml( # If the recipe_dir exists (no guarantee within this function) , we can # find the meta.yaml within it. - recipe_name = "meta.yaml" if recipe_version == 1 else "recipe.yaml" + recipe_name = "meta.yaml" if recipe_version == 0 else "recipe.yaml" recipe_fname = os.path.join(recipe_dir or "", recipe_name) sources_section = get_section(meta, "source", lints, recipe_version) @@ -121,7 +121,7 @@ def lintify_meta_yaml( ) build_requirements = requirements_section.get("build", []) run_reqs = requirements_section.get("run", []) - if recipe_version == 2: + if recipe_version == 1: test_section = get_section(meta, "tests", lints, recipe_version) else: test_section = get_section(meta, "test", lints, recipe_version) @@ -135,12 +135,12 @@ def lintify_meta_yaml( # 0: Top level keys should be expected unexpected_sections = [] - if recipe_version == 1: + if recipe_version == 0: expected_keys = EXPECTED_SECTION_ORDER else: expected_keys = ( - conda_recipe_v2_linter.EXPECTED_SINGLE_OUTPUT_SECTION_ORDER - + conda_recipe_v2_linter.EXPECTED_MULTIPLE_OUTPUT_SECTION_ORDER + conda_recipe_v1_linter.EXPECTED_SINGLE_OUTPUT_SECTION_ORDER + + conda_recipe_v1_linter.EXPECTED_MULTIPLE_OUTPUT_SECTION_ORDER ) for section in major_sections: @@ -175,8 +175,8 @@ def lintify_meta_yaml( lint_license_cannot_be_unknown(about_section, lints) # 6: Selectors should be in a tidy form. - if recipe_version == 1: - # rattler-build does not have selectors in comments form + if recipe_version == 0: + # v1 does not have selectors in comments form lint_selectors_should_be_in_tidy_form(recipe_fname, lints, hints) # 7: The build section should have a build number. @@ -195,9 +195,9 @@ def lintify_meta_yaml( lint_should_be_empty_line(recipe_fname, lints) # 12: License family must be valid (conda-build checks for that) - # we skip it for rattler builds as it will validate it + # we skip it for v1 builds as it will validate it # See more: https://prefix-dev.github.io/rattler-build/latest/reference/recipe_file/#about-section - if recipe_version == 1: + if recipe_version == 0: try: ensure_valid_license_family(meta) except RuntimeError as e: @@ -210,8 +210,8 @@ def lintify_meta_yaml( ) # 13: Check that the recipe name is valid - if recipe_version == 2: - conda_recipe_v2_linter.lint_recipe_name(meta, lints) + if recipe_version == 1: + conda_recipe_v1_linter.lint_recipe_name(meta, lints) else: lint_recipe_name( package_section, @@ -228,7 +228,7 @@ def lintify_meta_yaml( lint_usage_of_legacy_patterns(requirements_section, lints) # 16: Subheaders should be in the allowed subheadings - if recipe_version == 1: + if recipe_version == 0: lint_subheaders(major_sections, meta, lints) # 17: Validate noarch @@ -238,7 +238,7 @@ def lintify_meta_yaml( conda_build_config_filename = None if recipe_dir: cbc_file = "conda_build_config.yaml" - if recipe_version == 2: + if recipe_version == 1: cbc_file = "variants.yaml" conda_build_config_filename = find_local_config_file( @@ -266,9 +266,9 @@ def lintify_meta_yaml( # 18: noarch doesn't work with selectors for runtime dependencies noarch_platforms = len(forge_yaml.get("noarch_platforms", [])) > 1 - if recipe_version == 2: + if recipe_version == 1: raw_requirements_section = meta.get("requirements", {}) - lint_recipe_v2_noarch_and_runtime_dependencies( + lint_recipe_v1_noarch_and_runtime_dependencies( noarch_value, raw_requirements_section, build_section, @@ -285,8 +285,8 @@ def lintify_meta_yaml( ) # 19: check version - if recipe_version == 2: - conda_recipe_v2_linter.lint_package_version(meta, lints) + if recipe_version == 1: + conda_recipe_v1_linter.lint_package_version(meta, lints) else: lint_package_version(package_section, lints) @@ -379,7 +379,7 @@ def run_conda_forge_specific( recipe_dir, lints, hints, - recipe_version: int = 1, + recipe_version: int = 0, ): gh = github.Github(os.environ["GH_TOKEN"]) @@ -404,8 +404,8 @@ def run_conda_forge_specific( maintainers = extra_section.get("recipe-maintainers", []) recipe_dirname = os.path.basename(recipe_dir) if recipe_dir else "recipe" - if recipe_version == 2: - recipe_name = conda_recipe_v2_linter.get_recipe_name(meta) + if recipe_version == 1: + recipe_name = conda_recipe_v1_linter.get_recipe_name(meta) else: recipe_name = package_section.get("name", "").strip() is_staged_recipes = recipe_dirname != "recipe" @@ -450,7 +450,7 @@ def run_conda_forge_specific( ) url = None - if recipe_version == 2: + if recipe_version == 1: for source_url in sources_section: if source_url.startswith("https://pypi.io/packages/source/"): url = source_url @@ -515,7 +515,7 @@ def run_conda_forge_specific( host_reqs = requirements_section.get("host") or [] run_reqs = requirements_section.get("run") or [] for out in outputs_section: - if recipe_version == 2: + if recipe_version == 1: output_requirements = rattler_loader.load_all_requirements(out) build_reqs += output_requirements.get("build") or [] host_reqs += output_requirements.get("host") or [] @@ -650,7 +650,7 @@ def main( else: meta = get_yaml().load(Path(recipe_file)) - recipe_version = 2 if build_tool == RATTLER_BUILD_TOOL else 1 + recipe_version = 1 if build_tool == RATTLER_BUILD_TOOL else 0 results, hints = lintify_meta_yaml( meta, recipe_dir, diff --git a/conda_smithy/linter/conda_recipe_v2_linter.py b/conda_smithy/linter/conda_recipe_v1_linter.py similarity index 100% rename from conda_smithy/linter/conda_recipe_v2_linter.py rename to conda_smithy/linter/conda_recipe_v1_linter.py diff --git a/conda_smithy/linter/hints.py b/conda_smithy/linter/hints.py index 12cb1e1c8..29b5ed911 100644 --- a/conda_smithy/linter/hints.py +++ b/conda_smithy/linter/hints.py @@ -5,7 +5,7 @@ import sys from glob import glob -from conda_smithy.linter import conda_recipe_v2_linter +from conda_smithy.linter import conda_recipe_v1_linter from conda_smithy.linter.errors import HINT_NO_ARCH from conda_smithy.linter.utils import find_local_config_file, is_selector_line from conda_smithy.utils import get_yaml @@ -32,7 +32,7 @@ def hint_suggest_noarch( conda_forge, recipe_fname, hints, - recipe_version: int = 1, + recipe_version: int = 0, ): if ( noarch_value is None @@ -41,8 +41,8 @@ def hint_suggest_noarch( and ("pip" in build_reqs) and (is_staged_recipes or not conda_forge) ): - if recipe_version == 2: - conda_recipe_v2_linter.hint_noarch_usage( + if recipe_version == 1: + conda_recipe_v1_linter.hint_noarch_usage( build_reqs, raw_requirements_section, hints ) else: diff --git a/conda_smithy/linter/lints.py b/conda_smithy/linter/lints.py index 2038d651e..fe5a6cbc3 100644 --- a/conda_smithy/linter/lints.py +++ b/conda_smithy/linter/lints.py @@ -10,7 +10,7 @@ from rattler_build_conda_compat.loader import parse_recipe_config_file from ruamel.yaml import CommentedSeq -from conda_smithy.linter import conda_recipe_v2_linter +from conda_smithy.linter import conda_recipe_v1_linter from conda_smithy.linter.utils import ( EXPECTED_SECTION_ORDER, FIELDS, @@ -30,17 +30,17 @@ def lint_section_order( major_sections: List[str], lints: List[str], - recipe_version: int = 1, + recipe_version: int = 0, ): - if recipe_version == 1: + if recipe_version == 0: order = EXPECTED_SECTION_ORDER else: if "outputs" in major_sections: order = ( - conda_recipe_v2_linter.EXPECTED_MULTIPLE_OUTPUT_SECTION_ORDER + conda_recipe_v1_linter.EXPECTED_MULTIPLE_OUTPUT_SECTION_ORDER ) else: - order = conda_recipe_v2_linter.EXPECTED_SINGLE_OUTPUT_SECTION_ORDER + order = conda_recipe_v1_linter.EXPECTED_SINGLE_OUTPUT_SECTION_ORDER section_order_sorted = sorted(major_sections, key=order.index) if major_sections != section_order_sorted: @@ -55,9 +55,9 @@ def lint_section_order( ) -def lint_about_contents(about_section, lints, recipe_version: int = 1): +def lint_about_contents(about_section, lints, recipe_version: int = 0): expected_section = [ - "homepage" if recipe_version == 2 else "home", + "homepage" if recipe_version == 1 else "home", "license", "summary", ] @@ -88,10 +88,10 @@ def lint_recipe_have_tests( outputs_section, lints, hints, - recipe_version: int = 1, + recipe_version: int = 0, ): - if recipe_version == 2: - conda_recipe_v2_linter.lint_recipe_tests( + if recipe_version == 1: + conda_recipe_v1_linter.lint_recipe_tests( recipe_dir, test_section, outputs_section, lints, hints ) return @@ -246,12 +246,12 @@ def lint_license_family_should_be_valid( license: str, needed_families: List[str], lints: List[str], - recipe_version: int = 1, + recipe_version: int = 0, ) -> None: lint_msg = "license_file entry is missing, but is required." license_file = about_section.get("license_file", None) if not license_file: - if recipe_version == 2: + if recipe_version == 1: lints.append(lint_msg) else: license_family = about_section.get( @@ -317,7 +317,7 @@ def lint_noarch(noarch_value: Optional[str], lints): ) -def lint_recipe_v2_noarch_and_runtime_dependencies( +def lint_recipe_v1_noarch_and_runtime_dependencies( noarch_value: Optional[Literal["python", "generic"]], raw_requirements_section: Dict[str, Any], build_section: Dict[str, Any], @@ -325,7 +325,7 @@ def lint_recipe_v2_noarch_and_runtime_dependencies( lints: List[str], ) -> None: if noarch_value: - conda_recipe_v2_linter.lint_usage_of_selectors_for_noarch( + conda_recipe_v1_linter.lint_usage_of_selectors_for_noarch( noarch_value, raw_requirements_section, build_section, @@ -419,11 +419,11 @@ def lint_legacy_usage_of_compilers(build_reqs, lints): def lint_single_space_in_pinned_requirements( requirements_section, lints, - recipe_version: int = 1, + recipe_version: int = 0, ): for section, requirements in requirements_section.items(): for requirement in requirements or []: - if recipe_version == 2: + if recipe_version == 1: req = requirement symbol_to_check = "${{" else: @@ -512,13 +512,13 @@ def lint_non_noarch_builds( ) -def lint_jinja_var_references(meta_fname, hints, recipe_version: int = 1): +def lint_jinja_var_references(meta_fname, hints, recipe_version: int = 0): bad_vars = [] bad_lines = [] jinja_pattern = ( JINJA_VAR_PAT - if recipe_version == 1 - else conda_recipe_v2_linter.JINJA_VAR_PAT + if recipe_version == 0 + else conda_recipe_v1_linter.JINJA_VAR_PAT ) if os.path.exists(meta_fname): with open(meta_fname) as fh: @@ -532,7 +532,7 @@ def lint_jinja_var_references(meta_fname, hints, recipe_version: int = 1): if bad_vars: hint_message = ( "``{{}}``" - if recipe_version == 1 + if recipe_version == 0 else "``${{}}``" ) hints.append( @@ -563,9 +563,9 @@ def lint_pin_subpackages( outputs_section, package_section, lints, - recipe_version: int = 1, + recipe_version: int = 0, ): - if recipe_version == 2: + if recipe_version == 1: meta = render_recipe_with_context(meta) # use the rendered versions here package_section = meta.get("package", {}) @@ -573,7 +573,7 @@ def lint_pin_subpackages( subpackage_names = [] for out in outputs_section: - if recipe_version == 2: + if recipe_version == 1: if out.get("package", {}).get("name"): subpackage_names.append(out["package"]["name"]) elif "name" in out: @@ -610,7 +610,7 @@ def check_pins(pinning_section): ) def check_pins_build_and_requirements(top_level): - if recipe_version == 1: + if recipe_version == 0: if "build" in top_level and "run_exports" in top_level["build"]: check_pins(top_level["build"]["run_exports"]) if ( @@ -685,12 +685,12 @@ def lint_check_usage_of_whls(meta_fname, noarch_value, lints, hints): def lint_rust_licenses_are_bundled( build_reqs: Optional[List[str]], lints: List[str], - recipe_version: int = 1, + recipe_version: int = 0, ): if not build_reqs: return - if recipe_version == 2: + if recipe_version == 1: has_rust = "${{ compiler('rust') }}" in build_reqs else: has_rust = "{{ compiler('rust') }}" in build_reqs @@ -705,12 +705,12 @@ def lint_rust_licenses_are_bundled( def lint_go_licenses_are_bundled( build_reqs: Optional[List[str]], lints: List[str], - recipe_version: int = 1, + recipe_version: int = 0, ): if not build_reqs: return - if recipe_version == 2: + if recipe_version == 1: has_go = "${{ compiler('go') }}" in build_reqs else: has_go = "{{ compiler('go') }}" in build_reqs @@ -729,16 +729,16 @@ def lint_stdlib( conda_build_config_filename, lints, hints, - recipe_version: int = 1, + recipe_version: int = 0, ): global_build_reqs = requirements_section.get("build") or [] global_run_reqs = requirements_section.get("run") or [] - if recipe_version == 2: + if recipe_version == 1: global_constraints = requirements_section.get("run_constraints") or [] else: global_constraints = requirements_section.get("run_constrained") or [] - if recipe_version == 2: + if recipe_version == 1: jinja_stdlib_c = '`${{ stdlib("c") }}`' else: jinja_stdlib_c = '`{{ stdlib("c") }}`' @@ -749,7 +749,7 @@ def lint_stdlib( "each output of the recipe using a compiler. For further details, please " "see https://github.com/conda-forge/conda-forge.github.io/issues/2102." ) - if recipe_version == 1: + if recipe_version == 0: pat_compiler_stub = re.compile( "(m2w64_)?(c|cxx|fortran|rust)_compiler_stub" ) @@ -760,7 +760,7 @@ def lint_stdlib( output_reqs = [x.get("requirements", {}) for x in outputs] # deal with cb2 recipes (no build/host/run distinction) - if recipe_version == 1: + if recipe_version == 0: output_reqs = [ {"host": x, "run": x} if isinstance(x, CommentedSeq) else x for x in output_reqs @@ -769,7 +769,7 @@ def lint_stdlib( # collect output requirements output_build_reqs = [x.get("build", []) or [] for x in output_reqs] output_run_reqs = [x.get("run", []) or [] for x in output_reqs] - if recipe_version == 2: + if recipe_version == 1: output_contraints = [ x.get("run_constraints", []) or [] for x in output_reqs ] @@ -794,7 +794,7 @@ def flatten_reqs(reqs): # this check needs to be done per output --> use separate (unflattened) requirements for build_reqs in all_build_reqs: has_compiler = any(pat_compiler_stub.match(rq) for rq in build_reqs) - stdlib_stub = "c_stdlib_stub" if recipe_version == 1 else "${{ stdlib" + stdlib_stub = "c_stdlib_stub" if recipe_version == 0 else "${{ stdlib" if has_compiler and stdlib_stub not in build_reqs: if stdlib_lint not in lints: lints.append(stdlib_lint) @@ -827,7 +827,7 @@ def flatten_reqs(reqs): # stdlib issues in CBC ( conda-build-config ) cbc_osx = {} - if recipe_version == 2: + if recipe_version == 1: platform_namespace = { "unix": True, "osx": True, diff --git a/conda_smithy/linter/utils.py b/conda_smithy/linter/utils.py index 6d7fdd465..163e76ba7 100644 --- a/conda_smithy/linter/utils.py +++ b/conda_smithy/linter/utils.py @@ -47,11 +47,11 @@ RATTLER_BUILD_TOOL = "rattler-build" -def get_section(parent, name, lints, recipe_version: int = 1): - if recipe_version == 1: +def get_section(parent, name, lints, recipe_version: int = 0): + if recipe_version == 0: return get_meta_section(parent, name, lints) - elif recipe_version == 2: - return get_recipe_v2_section(parent, name) + elif recipe_version == 1: + return get_recipe_v1_section(parent, name) else: raise ValueError(f"Unknown recipe version: {recipe_version}") @@ -72,7 +72,7 @@ def get_meta_section(parent, name, lints): return section -def get_recipe_v2_section(meta, name) -> Union[Dict, List[Dict]]: +def get_recipe_v1_section(meta, name) -> Union[Dict, List[Dict]]: if name == "requirements": return rattler_loader.load_all_requirements(meta) elif name == "tests": diff --git a/news/rename-v2-v1.rst b/news/rename-v2-v1.rst new file mode 100644 index 000000000..6dc086331 --- /dev/null +++ b/news/rename-v2-v1.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* The conda recipe version was renamed from ``{1, 2}`` to ``{0, 1}``. (#2031) + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/tests/conftest.py b/tests/conftest.py index 4bf2ac0fb..d16c0a6b6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -642,7 +642,7 @@ def jinja_env(): @pytest.fixture(scope="function") -def rattler_noarch_recipe_with_context(testing_workdir: Path, recipe_dirname): +def v1_noarch_recipe_with_context(testing_workdir: Path, recipe_dirname): with open(os.path.join(testing_workdir, "conda-forge.yml"), "w") as f: config = { "recipe_dir": recipe_dirname, @@ -680,9 +680,7 @@ def rattler_noarch_recipe_with_context(testing_workdir: Path, recipe_dirname): @pytest.fixture(scope="function") -def rattler_recipe_with_multiple_outputs( - testing_workdir: Path, recipe_dirname -): +def v1_recipe_with_multiple_outputs(testing_workdir: Path, recipe_dirname): with open(os.path.join(testing_workdir, "conda-forge.yml"), "w") as f: config = { "recipe_dir": recipe_dirname, diff --git a/tests/test_lint_recipe.py b/tests/test_lint_recipe.py index 1848c16de..55f6ae873 100644 --- a/tests/test_lint_recipe.py +++ b/tests/test_lint_recipe.py @@ -57,7 +57,7 @@ def test_stdlib_lint(comp_lang): "comp_lang", ["c", "cxx", "fortran", "rust", "m2w64_c", "m2w64_cxx", "m2w64_fortran"], ) -def test_rattler_stdlib_hint(comp_lang): +def test_v1_stdlib_hint(comp_lang): expected_message = "This recipe is using a compiler" with tmp_directory() as recipe_dir: @@ -188,7 +188,7 @@ def test_osx_noarch_hint(where): assert not any(h.startswith(avoid_message) for h in hints) -def test_recipe_v2_osx_noarch_hint(): +def test_recipe_v1_osx_noarch_hint(): # don't warn on packages that are using __osx as a noarch-marker, see # https://conda-forge.org/docs/maintainer/knowledge_base/#noarch-packages-with-os-specific-dependencies avoid_message = "You're setting a constraint on the `__osx` virtual" @@ -324,7 +324,7 @@ def test_cbc_osx_lints( assert any(lint.startswith(exp_lint) for lint in lints) -@pytest.mark.parametrize("recipe_version", [(1), (2)]) +@pytest.mark.parametrize("recipe_version", [0, 1]) def test_license_file_required(recipe_version: int): meta = { "about": { @@ -340,7 +340,7 @@ def test_license_file_required(recipe_version: int): assert expected_message in lints -@pytest.mark.parametrize("recipe_version", [(1), (2)]) +@pytest.mark.parametrize("recipe_version", [0, 1]) def test_license_file_empty(recipe_version: int): meta = { "about": { @@ -409,7 +409,7 @@ def test_license_file_empty(recipe_version: int): (None, None, ["10.12", "11.0"], "You are"), ], ) -def test_rattler_cbc_osx_hints( +def test_v1_cbc_osx_hints( std_selector, with_linux, reverse_arch, macdt, v_std, sdk, exp_lint ): with tmp_directory() as recipe_dir: @@ -518,9 +518,9 @@ def test_bad_top_level(self): expected_msg = "The top level meta key sources is unexpected" self.assertIn(expected_msg, lints) - def test_recipe_v2_bad_top_level(self): + def test_recipe_v1_bad_top_level(self): meta = OrderedDict([["package", {}], ["build", {}], ["sources", {}]]) - lints, hints = linter.lintify_meta_yaml(meta, recipe_version=2) + lints, hints = linter.lintify_meta_yaml(meta, recipe_version=1) expected_msg = "The top level meta key sources is unexpected" self.assertIn(expected_msg, lints) @@ -575,7 +575,7 @@ def test_missing_about_home(self): def test_missing_about_homepage_empty(self): meta = {"about": {"homepage": "", "summary": "", "license": ""}} - lints, hints = linter.lintify_meta_yaml(meta, recipe_version=2) + lints, hints = linter.lintify_meta_yaml(meta, recipe_version=1) expected_message = ( "The homepage item is expected in the about section." ) @@ -691,25 +691,25 @@ def test_test_section(self): "It looks like the 'foobar' output doesn't have any tests.", hints ) - def test_recipe_v2_test_section(self): + def test_recipe_v1_test_section(self): expected_message = "The recipe must have some tests." - lints, hints = linter.lintify_meta_yaml({}, recipe_version=2) + lints, hints = linter.lintify_meta_yaml({}, recipe_version=1) self.assertIn(expected_message, lints) lints, hints = linter.lintify_meta_yaml( - {"tests": {"script": "sys"}}, recipe_version=2 + {"tests": {"script": "sys"}}, recipe_version=1 ) self.assertNotIn(expected_message, lints) lints, hints = linter.lintify_meta_yaml( - {"outputs": [{"name": "foo"}]}, recipe_version=2 + {"outputs": [{"name": "foo"}]}, recipe_version=1 ) self.assertIn(expected_message, lints) lints, hints = linter.lintify_meta_yaml( {"outputs": [{"name": "foo", "tests": {"python": "sys"}}]}, - recipe_version=2, + recipe_version=1, ) self.assertNotIn(expected_message, lints) @@ -722,7 +722,7 @@ def test_recipe_v2_test_section(self): }, ] }, - recipe_version=2, + recipe_version=1, ) self.assertNotIn(expected_message, lints) self.assertIn( @@ -744,21 +744,21 @@ def test_test_section_with_recipe(self): lints, hints = linter.lintify_meta_yaml({}, recipe_dir) self.assertNotIn(expected_message, lints) - def test_recipe_v2_test_section_with_recipe(self): - # rattler-build support legacy run_test.py, so we need to test it + def test_recipe_v1_test_section_with_recipe(self): + # rattler-build supports legacy run_test.py, so we need to test it expected_message = "The recipe must have some tests." with tmp_directory() as recipe_dir: lints, hints = linter.lintify_meta_yaml( - {}, recipe_dir, recipe_version=2 + {}, recipe_dir, recipe_version=1 ) self.assertIn(expected_message, lints) with open(os.path.join(recipe_dir, "run_test.py"), "w") as fh: fh.write("# foo") lints, hints = linter.lintify_meta_yaml( - {}, recipe_dir, recipe_version=2 + {}, recipe_dir, recipe_version=1 ) self.assertNotIn(expected_message, lints) @@ -791,7 +791,7 @@ def test_jinja2_vars(self): _, hints = linter.lintify_meta_yaml({}, recipe_dir) self.assertTrue(any(h.startswith(expected_message) for h in hints)) - def test_recipe_v2_jinja2_vars(self): + def test_recipe_v1_jinja2_vars(self): expected_message = ( "Jinja2 variable references are suggested to take a ``${{" "}}`` form. See lines %s." @@ -818,7 +818,7 @@ def test_recipe_v2_jinja2_vars(self): ) _, hints = linter.lintify_meta_yaml( - {}, recipe_dir, recipe_version=2 + {}, recipe_dir, recipe_version=1 ) self.assertTrue(any(h.startswith(expected_message) for h in hints)) @@ -1121,7 +1121,7 @@ def assert_noarch_selector(meta_string, is_good=False): """ ) - def test_recipe_v2_noarch_selectors(self): + def test_recipe_v1_noarch_selectors(self): expected_start = "`noarch` packages can't have" with tmp_directory() as recipe_dir: @@ -1306,7 +1306,7 @@ def assert_noarch_hint(meta_string, is_good=False): is_good=True, ) - def test_suggest_rattler_noarch(self): + def test_suggest_v1_noarch(self): expected_start = "Whenever possible python packages should use noarch." with tmp_directory() as recipe_dir: @@ -1688,9 +1688,9 @@ def test_recipe_name(self): ) self.assertIn(expected_message, lints) - def test_recipe_v2_recipe_name(self): + def test_recipe_v1_recipe_name(self): meta = {"package": {"name": "mp++"}} - lints, _ = linter.lintify_meta_yaml(meta, recipe_version=2) + lints, _ = linter.lintify_meta_yaml(meta, recipe_version=1) expected_message = ( "Recipe name has invalid characters. only lowercase alpha, " "numeric, underscores, hyphens and dots allowed" @@ -1702,7 +1702,7 @@ def test_recipe_v2_recipe_name(self): "package": {"name": "${{ blah }}"}, } # noqa lints, _ = linter.lintify_meta_yaml( - meta_with_context, recipe_version=2 + meta_with_context, recipe_version=1 ) expected_message = ( "Recipe name has invalid characters. only lowercase alpha, " @@ -1712,7 +1712,7 @@ def test_recipe_v2_recipe_name(self): meta_with_context = {"recipe": {"name": "mp++"}, "outputs": []} # noqa lints, _ = linter.lintify_meta_yaml( - meta_with_context, recipe_version=2 + meta_with_context, recipe_version=1 ) expected_message = ( "Recipe name has invalid characters. only lowercase alpha, " @@ -1998,17 +1998,17 @@ def test_version(self): lints, hints = linter.lintify_meta_yaml(meta) assert any(lint.startswith(expected_message) for lint in lints) - def test_recipe_v2_version(self): + def test_recipe_v1_version(self): meta = {"package": {"name": "python", "version": "3.6.4"}} expected_message = "Package version 3.6.4 doesn't match conda spec" - lints, hints = linter.lintify_meta_yaml(meta, recipe_version=2) + lints, hints = linter.lintify_meta_yaml(meta, recipe_version=1) self.assertNotIn(expected_message, lints) meta = {"package": {"name": "python", "version": "2.0.0~alpha0"}} expected_message = ( "Package version 2.0.0~alpha0 doesn't match conda spec" ) - lints, hints = linter.lintify_meta_yaml(meta, recipe_version=2) + lints, hints = linter.lintify_meta_yaml(meta, recipe_version=1) assert any(lint.startswith(expected_message) for lint in lints) # when having multiple outputs it should use recipe keyword @@ -2016,16 +2016,16 @@ def test_recipe_v2_version(self): expected_message = ( "Package version 2.0.0~alpha0 doesn't match conda spec" ) - lints, hints = linter.lintify_meta_yaml(meta, recipe_version=2) + lints, hints = linter.lintify_meta_yaml(meta, recipe_version=1) assert any(lint.startswith(expected_message) for lint in lints) - def test_recipe_v2_version_with_context(self): + def test_recipe_v1_version_with_context(self): meta = { "context": {"foo": "3.6.4"}, "package": {"name": "python", "version": "${{ foo }}"}, } expected_message = "Package version 3.6.4 doesn't match conda spec" - lints, hints = linter.lintify_meta_yaml(meta, recipe_version=2) + lints, hints = linter.lintify_meta_yaml(meta, recipe_version=1) self.assertNotIn(expected_message, lints) meta = { @@ -2035,7 +2035,7 @@ def test_recipe_v2_version_with_context(self): expected_message = ( "Package version 2.0.0~alpha0 doesn't match conda spec" ) - lints, hints = linter.lintify_meta_yaml(meta, recipe_version=2) + lints, hints = linter.lintify_meta_yaml(meta, recipe_version=1) assert any(lint.startswith(expected_message) for lint in lints) @unittest.skipUnless(is_gh_token_set(), "GH_TOKEN not set") @@ -2108,7 +2108,7 @@ def test_single_space_pins(self): ] self.assertEqual(expected_messages, filtered_lints) - def test_recipe_v2_single_space_pins(self): + def test_recipe_v1_single_space_pins(self): meta = { "requirements": { "build": ["${{ compiler('c') }}", "python >=3", "pip 19"], @@ -2116,7 +2116,7 @@ def test_recipe_v2_single_space_pins(self): "run": ["xonsh>1.0", "conda= 4.*", "conda-smithy<=54.*"], } } - lints, hints = linter.lintify_meta_yaml(meta, recipe_version=2) + lints, hints = linter.lintify_meta_yaml(meta, recipe_version=1) filtered_lints = [ lint for lint in lints if lint.startswith("``requirements: ") ] @@ -2247,12 +2247,12 @@ def test_mpl_base_hint_outputs(self): self.assertTrue(any(hint.startswith(expected) for hint in hints)) -@pytest.mark.parametrize("recipe_version", [2, 1]) +@pytest.mark.parametrize("recipe_version", [0, 1]) def test_rust_license_bundling(recipe_version: int): # Case where go-licenses is missing compiler = ( "${{ compiler('rust') }}" - if recipe_version == 2 + if recipe_version == 1 else "{{ compiler('rust') }}" ) meta_missing_license = { @@ -2279,12 +2279,12 @@ def test_rust_license_bundling(recipe_version: int): assert expected_msg not in lints -@pytest.mark.parametrize("recipe_version", [2, 1]) +@pytest.mark.parametrize("recipe_version", [0, 1]) def test_go_license_bundling(recipe_version: int): # Case where go-licenses is missing compiler = ( "${{ compiler('go') }}" - if recipe_version == 2 + if recipe_version == 1 else "{{ compiler('go') }}" ) meta_missing_license = { @@ -2592,7 +2592,7 @@ def test_lint_wheels(tmp_path, yaml_block, annotation): assert any(expected_message in hint for hint in hints) -@pytest.mark.parametrize("recipe_version", [1, 2]) +@pytest.mark.parametrize("recipe_version", [0, 1]) def test_pin_compatible_in_run_exports(recipe_version: int): meta = { "package": { @@ -2600,7 +2600,7 @@ def test_pin_compatible_in_run_exports(recipe_version: int): } } - if recipe_version == 2: + if recipe_version == 1: meta["requirements"] = { "run_exports": ['${{ pin_compatible("apackage") }}'], } @@ -2616,9 +2616,9 @@ def test_pin_compatible_in_run_exports(recipe_version: int): assert any(lint.startswith(expected) for lint in lints) -@pytest.mark.parametrize("recipe_version", [1, 2]) +@pytest.mark.parametrize("recipe_version", [0, 1]) def test_pin_compatible_in_run_exports_output(recipe_version: int): - if recipe_version == 2: + if recipe_version == 1: meta = { "recipe": { "name": "apackage", diff --git a/tests/test_utils.py b/tests/test_utils.py index 4d963cd76..5518dcfdc 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -35,11 +35,11 @@ def test_get_feedstock_name_from_metadata(noarch_recipe): def test_get_feedstock_name_from_rattler_metadata( - rattler_noarch_recipe_with_context, + v1_noarch_recipe_with_context, ): - feedstock_dir = rattler_noarch_recipe_with_context[0] + feedstock_dir = v1_noarch_recipe_with_context[0] metadata = _get_metadata_from_feedstock_dir( - feedstock_dir, rattler_noarch_recipe_with_context[1] + feedstock_dir, v1_noarch_recipe_with_context[1] ) feedstock_name = get_feedstock_name_from_meta(metadata) @@ -48,11 +48,11 @@ def test_get_feedstock_name_from_rattler_metadata( def test_get_feedstock_name_from_rattler_metadata_multiple_outputs( - rattler_recipe_with_multiple_outputs, + v1_recipe_with_multiple_outputs, ): - feedstock_dir = rattler_recipe_with_multiple_outputs[0] + feedstock_dir = v1_recipe_with_multiple_outputs[0] metadata = _get_metadata_from_feedstock_dir( - feedstock_dir, rattler_recipe_with_multiple_outputs[1] + feedstock_dir, v1_recipe_with_multiple_outputs[1] ) feedstock_name = get_feedstock_name_from_meta(metadata)