Skip to content

Commit

Permalink
fix: allow more syntax for tighten depends
Browse files Browse the repository at this point in the history
  • Loading branch information
beckermr committed Feb 23, 2025
1 parent 0fcc3a0 commit cc899ad
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
6 changes: 3 additions & 3 deletions recipe/patch_yaml/conda-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,6 @@ if:
version_le: 25.1.2
timestamp_le: 1740306410000 # 2025-02-23
then:
- replace_depends:
old: py-lief <0.17
new: py-lief <0.16.0a0
- tighten_depends:
name: py-lief
upper_bound: "0.16"
27 changes: 27 additions & 0 deletions recipe/patch_yaml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,33 @@ def _pin_stricter(fn, record, fix_dep, max_pin, upper_bound=None):

continue

if (
len(dep_parts) == 2
and dep_parts[1].startswith("<")
and upper_bound is not None
):
upper_bound = upper_bound.split(".")
if str(upper_bound[-1]) != "0":
upper_bound += ["0"]
upper_bound = ".".join(upper_bound)

old_upper = dep_parts[1].split("<")[1]
if old_upper.startswith("="):
# if the old pin is <=, we need to remove the =
# and we allow changes of eg <=15 to <15.0a0
# hence the condition includes >=
old_upper = old_upper[1:]
cond = parse_version(old_upper) >= parse_version(upper_bound)
else:
cond = parse_version(old_upper) > parse_version(upper_bound)
if cond:
depends[dep_idx] = "{} <{}a0".format(
dep_parts[0],
upper_bound,
)
record["depends"] = depends
continue


def _pin_looser(fn, record, fix_dep, max_pin=None, upper_bound=None):
depends = record.get("depends", ())
Expand Down

0 comments on commit cc899ad

Please sign in to comment.