diff --git a/setupsrc/pypdfium2_setup/autorelease_conda_raw.py b/setupsrc/pypdfium2_setup/autorelease_conda_raw.py index 9cbb07147..5379de55c 100644 --- a/setupsrc/pypdfium2_setup/autorelease_conda_raw.py +++ b/setupsrc/pypdfium2_setup/autorelease_conda_raw.py @@ -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) @@ -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)