Skip to content

Commit f61819e

Browse files
committed
add version bumping for v2 recipes
1 parent fa59207 commit f61819e

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

conda_forge_tick/migrators/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
import logging
66
import re
77
import typing
8-
from typing import Any, List, Optional, Sequence, Set
98
from pathlib import Path
9+
from typing import Any, List, Optional, Sequence, Set
10+
1011
import dateutil.parser
1112
import networkx as nx
12-
1313
from rattler_build_conda_compat import modify_recipe
1414

1515
from conda_forge_tick.contexts import FeedstockContext

conda_forge_tick/migrators/version.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
import random
66
import typing
77
import warnings
8+
from pathlib import Path
89
from typing import Any, List, Sequence
910

1011
import conda.exceptions
1112
import networkx as nx
1213
from conda.models.version import VersionOrder
14+
from rattler_build_conda_compat import modify_recipe
1315

1416
from conda_forge_tick.contexts import FeedstockContext
1517
from conda_forge_tick.migrators.core import Migrator
1618
from conda_forge_tick.models.pr_info import MigratorName
17-
from conda_forge_tick.os_utils import pushd
1819
from conda_forge_tick.update_deps import get_dep_updates_and_hints
1920
from conda_forge_tick.update_recipe import update_version
2021
from conda_forge_tick.utils import get_keys_default, sanitize_string
@@ -195,20 +196,29 @@ def migrate(
195196
) -> "MigrationUidTypedDict":
196197
version = attrs["new_version"]
197198

198-
with open(os.path.join(recipe_dir, "meta.yaml")) as fp:
199-
raw_meta_yaml = fp.read()
199+
path = Path(recipe_dir) / "meta.yaml"
200+
if not path.exists():
201+
path = Path(recipe_dir) / "recipe.yaml"
202+
if not path.exists():
203+
raise FileNotFoundError(
204+
f"Could not find meta.yaml or recipe.yaml in {recipe_dir}"
205+
)
200206

201-
updated_meta_yaml, errors = update_version(
202-
raw_meta_yaml,
203-
version,
204-
hash_type=hash_type,
205-
)
207+
if path.name == "recipe.yaml":
208+
updated_meta_yaml = modify_recipe.update_version(path, version)
209+
errors = []
210+
else:
211+
raw_meta_yaml = path.read_text()
212+
213+
updated_meta_yaml, errors = update_version(
214+
raw_meta_yaml,
215+
version,
216+
hash_type=hash_type,
217+
)
206218

207219
if len(errors) == 0 and updated_meta_yaml is not None:
208-
with pushd(recipe_dir):
209-
with open("meta.yaml", "w") as fp:
210-
fp.write(updated_meta_yaml)
211-
self.set_build_number("meta.yaml")
220+
path.write_text(updated_meta_yaml)
221+
self.set_build_number(str(path))
212222

213223
return super().migrate(recipe_dir, attrs)
214224
else:

0 commit comments

Comments
 (0)