Skip to content
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: 4 additions & 0 deletions conda_forge_tick/migrators/conda_forge_yaml_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


class CondaForgeYAMLCleanup(MiniMigrator):
allowed_schema_versions = {0, 1}
keys_to_remove = [
"min_r_ver",
"max_r_ver",
Expand All @@ -26,6 +27,9 @@ class CondaForgeYAMLCleanup(MiniMigrator):

def filter(self, attrs: "AttrsTypedDict", not_bad_str_start: str = "") -> bool:
"""remove recipes without a conda-forge.yml file that has the keys to remove or change"""
if super().filter(attrs):
return True

cfy = attrs.get("conda-forge.yml", {})
if any(key in cfy for key in (self.keys_to_remove + self.keys_to_change)):
return False
Expand Down
2 changes: 1 addition & 1 deletion conda_forge_tick/migrators/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def filter(self, attrs: "AttrsTypedDict", not_bad_str_start: str = "") -> bool:
bool :
True if node is to be skipped
"""
return True
return skip_migrator_due_to_schema(attrs, self.allowed_schema_versions)

def migrate(self, recipe_dir: str, attrs: "AttrsTypedDict", **kwargs: Any) -> None:
"""Perform the migration, updating the ``meta.yaml``
Expand Down
2 changes: 1 addition & 1 deletion conda_forge_tick/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def _parse_recipes(
"home": about.get("homepage"),
"license": about.get("license"),
"license_family": about.get("license"),
"license_file": about.get("license_file")[0],
"license_file": about.get("license_file", [None])[0],
"summary": about.get("summary"),
}
)
Expand Down
19 changes: 14 additions & 5 deletions tests/test_cfyaml_cleanup_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
piggy_back_migrations=[CondaForgeYAMLCleanup()],
)

YAML_PATH = os.path.join(os.path.dirname(__file__), "test_yaml")
YAML_PATHS = [
os.path.join(os.path.dirname(__file__), "test_yaml"),
os.path.join(os.path.dirname(__file__), "test_v1_yaml"),
]


@pytest.mark.parametrize(
Expand All @@ -27,14 +30,19 @@
("compiler_stack"),
],
)
def test_version_cfyaml_cleanup(cases, tmpdir):
@pytest.mark.parametrize("recipe_version", [0, 1])
def test_version_cfyaml_cleanup(cases, recipe_version, tmpdir):
yaml = YAML()

with open(os.path.join(YAML_PATH, "version_cfyaml_cleanup_simple.yaml")) as fp:
with open(
os.path.join(YAML_PATHS[recipe_version], "version_cfyaml_cleanup_simple.yaml")
) as fp:
in_yaml = fp.read()

with open(
os.path.join(YAML_PATH, "version_cfyaml_cleanup_simple_correct.yaml"),
os.path.join(
YAML_PATHS[recipe_version], "version_cfyaml_cleanup_simple_correct.yaml"
),
) as fp:
out_yaml = fp.read()

Expand All @@ -59,7 +67,8 @@ def test_version_cfyaml_cleanup(cases, tmpdir):
"migrator_version": Version.migrator_version,
"version": "0.9",
},
tmpdir=os.path.join(tmpdir, "recipe"),
tmpdir=os.path.join(tmpdir, "recipe" if recipe_version == 0 else "."),
recipe_version=recipe_version,
)

with open(cf_yml_pth) as fp:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_migrators.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def run_test_migration(
recipe_dir_p = tmpdir_p
elif recipe_version == 1:
tmpdir_p.joinpath(".ci_support").mkdir()
tmpdir_p.joinpath("recipe").mkdir()
tmpdir_p.joinpath("recipe").mkdir(exist_ok=True)
tmpdir_p.joinpath("recipe", "recipe.yaml").write_text(inp)

build_variants = (
Expand Down Expand Up @@ -527,7 +527,7 @@ def run_test_migration(
recipe_dir = str(recipe_dir_p)

# read the conda-forge.yml
cf_yml_path = Path(tmpdir).parent / "conda-forge.yml"
cf_yml_path = recipe_dir_p.parent / "conda-forge.yml"
cf_yml = cf_yml_path.read_text() if cf_yml_path.exists() else "{}"

# Load the meta.yaml (this is done in the graph)
Expand Down
45 changes: 45 additions & 0 deletions tests/test_v1_yaml/version_cfyaml_cleanup_simple.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
schema_version: 1

context:
version: 0.8

package:
name: viscm
version: ${{ version }}

source:
url: https://pypi.io/packages/source/v/viscm/viscm-v${{ version }}.zip
sha256: 5a9677fa4751c6dd18a5a74e7ec06848e4973d0ac0af3e4d795753b15a30c759

build:
number: 0
skip: win
noarch: python
script: python -m pip install --no-deps --ignore-installed .

requirements:
host:
- python
- pip
- numpy
run:
- python
- numpy
- matplotlib
- colorspacious

tests:
- python:
imports:
- viscm
pip_check: false

about:
license: MIT
# license_file: '' we need to an issue upstream to get a license in the source dist.
summary: A colormap tool
homepage: https://github.com/bids/viscm

extra:
recipe-maintainers:
- kthyng
45 changes: 45 additions & 0 deletions tests/test_v1_yaml/version_cfyaml_cleanup_simple_correct.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
schema_version: 1

context:
version: "0.9"

package:
name: viscm
version: ${{ version }}

source:
url: https://pypi.io/packages/source/v/viscm/viscm-${{ version }}.tar.gz
sha256: c770e4b76f726e653d2b7c2c73f71941a88de6eb47ccf8fb8e984b55562d05a2

build:
number: 0
skip: win
noarch: python
script: python -m pip install --no-deps --ignore-installed .

requirements:
host:
- python
- pip
- numpy
run:
- python
- numpy
- matplotlib
- colorspacious

tests:
- python:
imports:
- viscm
pip_check: false

about:
license: MIT
# license_file: '' we need to an issue upstream to get a license in the source dist.
summary: A colormap tool
homepage: https://github.com/bids/viscm

extra:
recipe-maintainers:
- kthyng
Loading