Skip to content

Commit

Permalink
prevent rebuilds without actual update in schedule (only)
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Nov 22, 2023
1 parent d766b03 commit 1daf1e7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions setupsrc/pypdfium2_setup/autorelease_conda_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@

def main():

# FIXME we currently traverse the whole list with max() - any chance of (elegantly) avoiding this while maintaining inherent correctness?

parser = argparse.ArgumentParser()
parser.add_argument("--pdfium-ver", default=None)
args = parser.parse_args()
if not args.pdfium_ver or args.pdfium_ver == "latest":
is_literal_latest = args.pdfium_ver == "latest"
if not args.pdfium_ver or is_literal_latest:
args.pdfium_ver = PdfiumVer.get_latest()
else:
args.pdfium_ver = int(args.pdfium_ver)
Expand All @@ -24,8 +27,10 @@ def main():
search = run_cmd(["conda", "search", "--json", "pypdfium2_raw", "--override-channels", "-c", "pypdfium2-team"], cwd=None, capture=True)
search = reversed(json.loads(search)["pypdfium2_raw"])

if is_literal_latest:
assert args.pdfium_ver > max([int(d["version"]) for d in search]), "Literal latest must resolve to a new version. This is done to avoid rebuilds without new version in scheduled releases. If you want to rebuild, omit --pdfium-ver or pass the resolved value."

# determine build number
# TODO `search` seems to be ordered by date, so we could probably break the iteration when we find a matching version. though for a new version, we have to traverse the full list anyway...
build = max([d["build_number"] for d in search if int(d["version"]) == args.pdfium_ver], default=None)
build = 0 if build is None else build+1
print(build, file=sys.stderr)
Expand Down

0 comments on commit 1daf1e7

Please sign in to comment.