|
5 | 5 | import random |
6 | 6 | import typing |
7 | 7 | import warnings |
| 8 | +from pathlib import Path |
8 | 9 | from typing import Any, List, Sequence |
9 | 10 |
|
10 | 11 | import conda.exceptions |
11 | 12 | import networkx as nx |
12 | 13 | from conda.models.version import VersionOrder |
| 14 | +from rattler_build_conda_compat import modify_recipe |
13 | 15 |
|
14 | 16 | from conda_forge_tick.contexts import FeedstockContext |
15 | 17 | from conda_forge_tick.migrators.core import Migrator |
16 | 18 | from conda_forge_tick.models.pr_info import MigratorName |
17 | | -from conda_forge_tick.os_utils import pushd |
18 | 19 | from conda_forge_tick.update_deps import get_dep_updates_and_hints |
19 | 20 | from conda_forge_tick.update_recipe import update_version |
20 | 21 | from conda_forge_tick.utils import get_keys_default, sanitize_string |
@@ -195,20 +196,29 @@ def migrate( |
195 | 196 | ) -> "MigrationUidTypedDict": |
196 | 197 | version = attrs["new_version"] |
197 | 198 |
|
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 | + ) |
200 | 206 |
|
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 | + ) |
206 | 218 |
|
207 | 219 | 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)) |
212 | 222 |
|
213 | 223 | return super().migrate(recipe_dir, attrs) |
214 | 224 | else: |
|
0 commit comments