Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rename v2 to v1 and v1 to v0 #2031

Merged
merged 9 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions conda_smithy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions conda_smithy/configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
52 changes: 26 additions & 26 deletions conda_smithy/lint_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -103,15 +103,15 @@ 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 = []
major_sections = list(meta.keys())

# 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)
Expand All @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -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)

Expand Down Expand Up @@ -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"])

Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 []
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions conda_smithy/linter/hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down
Loading
Loading