Skip to content
Closed
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
25 changes: 14 additions & 11 deletions conda_forge_tick/migrators/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import logging
import re
import typing
from pathlib import Path
from typing import Any, List, Sequence, Set

import dateutil.parser
import networkx as nx
from rattler_build_conda_compat import modify_recipe

from conda_forge_tick.contexts import FeedstockContext
from conda_forge_tick.lazy_json_backends import LazyJson
Expand Down Expand Up @@ -566,19 +568,20 @@ def set_build_number(self, filename: str) -> None:
Parameters
----------
filename : str
Path the the meta.yaml
Path to the recipe file (meta.yaml or recipe.yaml)
"""
with open(filename) as f:
raw = f.read()

new_myaml = update_build_number(
raw,
self.new_build_number,
build_patterns=self.build_patterns,
)
path = Path(filename)
if path.name == "recipe.yaml":
new_myaml = modify_recipe.update_build_number(self.new_build_number)
else:
raw = path.read_text()

with open(filename, "w") as f:
f.write(new_myaml)
new_myaml = update_build_number(
raw,
self.new_build_number,
build_patterns=self.build_patterns,
)
path.write_text(new_myaml)

def new_build_number(self, old_number: int) -> int:
"""Determine the new build number to use.
Expand Down
34 changes: 22 additions & 12 deletions conda_forge_tick/migrators/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
import random
import typing
import warnings
from pathlib import Path
from typing import Any, List, Sequence

import conda.exceptions
import networkx as nx
from conda.models.version import VersionOrder
from rattler_build_conda_compat import modify_recipe

from conda_forge_tick.contexts import FeedstockContext
from conda_forge_tick.migrators.core import Migrator
from conda_forge_tick.models.pr_info import MigratorName
from conda_forge_tick.os_utils import pushd
from conda_forge_tick.update_deps import get_dep_updates_and_hints
from conda_forge_tick.update_recipe import update_version
from conda_forge_tick.utils import get_keys_default, sanitize_string
Expand Down Expand Up @@ -195,20 +196,29 @@ def migrate(
) -> "MigrationUidTypedDict":
version = attrs["new_version"]

with open(os.path.join(recipe_dir, "meta.yaml")) as fp:
raw_meta_yaml = fp.read()
path = Path(recipe_dir) / "meta.yaml"
if not path.exists():
path = Path(recipe_dir) / "recipe.yaml"
if not path.exists():
raise FileNotFoundError(
f"Could not find meta.yaml or recipe.yaml in {recipe_dir}"
)

updated_meta_yaml, errors = update_version(
raw_meta_yaml,
version,
hash_type=hash_type,
)
if path.name == "recipe.yaml":
updated_meta_yaml = modify_recipe.update_version(path, version)
errors = []
else:
raw_meta_yaml = path.read_text()

updated_meta_yaml, errors = update_version(
raw_meta_yaml,
version,
hash_type=hash_type,
)

if len(errors) == 0 and updated_meta_yaml is not None:
with pushd(recipe_dir):
with open("meta.yaml", "w") as fp:
fp.write(updated_meta_yaml)
self.set_build_number("meta.yaml")
path.write_text(updated_meta_yaml)
self.set_build_number(str(path))

return super().migrate(recipe_dir, attrs)
else:
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies:
- python-graphviz
- python-rapidjson
- rattler-build
- rattler-build-conda-compat
- requests
- ruamel.yaml
- ruamel.yaml.jinja2
Expand Down