Skip to content

Commit

Permalink
slightly deduplicate code from previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Dec 8, 2023
1 parent cef2801 commit 5963856
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions setupsrc/pypdfium2_setup/packaging_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,23 +145,23 @@ def get_latest():
return int( tag.split("/")[-1] )

@staticmethod
@functools.lru_cache(maxsize=1)
def get_latest_conda_pdfium():
search = run_conda_search("pdfium-binaries", "bblanchon")
get_version = lambda d: int(d["version"].split(".")[2])
search = sorted(search, key=lambda d: get_version(d), reverse=True)
result = get_version(search[0])
print(f"Resolved latest conda pdfium to {result}", file=sys.stderr)
@functools.lru_cache(maxsize=2)
def _get_latest_conda_for(package, channel, v_func):
search = run_conda_search(package, channel)
search = sorted(search, key=lambda d: v_func(d["version"]), reverse=True)
result = v_func(search[0]["version"])
print(f"Resolved latest {channel}::{package} to {result}", file=sys.stderr)
return result

@staticmethod
@functools.lru_cache(maxsize=1)
def get_latest_conda_pdfium():
return PdfiumVer._get_latest_conda_for(
"pdfium-binaries", "bblanchon", lambda v: int(v.split(".")[2])
)

def get_latest_conda_bindings():
search = run_conda_search("pypdfium2_raw", "pypdfium2-team")
search = sorted(search, key=lambda d: int(d["version"]), reverse=True)
result = int(search[0]["version"])
print(f"Resolved latest conda pdfium to {result}", file=sys.stderr)
return result
return PdfiumVer._get_latest_conda_for(
"pypdfium2_raw", "pypdfium2-team", lambda v: int(v)
)

@classmethod
def to_full(cls, v_short):
Expand Down

0 comments on commit 5963856

Please sign in to comment.