Skip to content

Commit 259eb2a

Browse files
committed
clean up
1 parent 4d4d4a9 commit 259eb2a

2 files changed

Lines changed: 21 additions & 16 deletions

File tree

holoviews/core/util/dependencies.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from types import ModuleType
1313

1414
_re_no = re.compile(r"\d+")
15-
_convert_int = lambda version_str: tuple(map(int, _re_no.findall(version_str)[:3]))
1615

1716

1817
class VersionError(Exception):
@@ -39,11 +38,15 @@ def _get_version(package_name):
3938
return "0.0.0"
4039

4140

41+
def _convert_int(version_str: str) -> tuple[int, ...]:
42+
"""Convert a version string to a tuple of integers."""
43+
return tuple(map(int, _re_no.findall(version_str)[:3]))
44+
45+
4246
@cache
4347
def _no_import_version(package_name) -> tuple[int, ...]:
4448
"""Get version number without importing the library"""
45-
version_str = _get_version(package_name)
46-
return _convert_int(version_str)
49+
return _convert_int(_get_version(package_name))
4750

4851

4952
_MIN_SUPPORTED_VERSION = {

scripts/check_latest_packages.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
from subprocess import DEVNULL, check_output
99

1010
PYTHON_VERSION = sys.version_info[:2]
11-
PLATFORM_SPECIFIERS = {"linux": "linux-64", "darwin": "osx-arm64", "win32": "win-64"}
12-
PLATFORM = PLATFORM_SPECIFIERS[sys.platform]
11+
PLATFORM = {"linux": "linux-64", "darwin": "osx-arm64", "win32": "win-64"}[sys.platform]
1312

1413
if sys.stdout.isatty() or os.environ.get("GITHUB_ACTIONS"):
1514
GREEN, RED, RESET = "\033[92m", "\033[91m", "\033[0m"
@@ -37,25 +36,28 @@ def python_check(item):
3736
return False
3837

3938

39+
def get_data(package):
40+
out = check_output(
41+
["pixi", "search", package, "--json", "--channel", "conda-forge", "--platform", PLATFORM],
42+
stderr=DEVNULL,
43+
)
44+
raw = json.loads(out)
45+
return [*raw.get("noarch", ()), *raw.get(PLATFORM, ())]
46+
47+
4048
def main(*packages):
4149
all_latest = True
4250
for package in sorted(packages):
43-
out = check_output(
44-
["pixi", "search", package, "--json", "--channel", "conda-forge"], stderr=DEVNULL
45-
)
46-
raw = json.loads(out)
47-
data = [*raw.get("noarch", ()), *raw.get(PLATFORM, ())]
51+
data = get_data(package)
4852
versions = {item["version"] for item in data if python_check(item)}
49-
latest_str = max(versions, key=convert_int)
50-
latest_int = convert_int(latest_str)
51-
current_str = version(package)
52-
current_int = convert_int(current_str)
53-
is_latest = current_int >= latest_int
53+
latest = max(versions, key=convert_int)
54+
current = version(package)
55+
is_latest = convert_int(current) >= convert_int(latest)
5456
all_latest &= is_latest
5557

5658
text_color = GREEN if is_latest else RED
5759
print(
58-
f"{text_color}Package: {package:<16} Current: {current_str:<16}\tLatest: {latest_str}{RESET}"
60+
f"{text_color}Package: {package:<16} Current: {current:<16}\tLatest: {latest}{RESET}"
5961
)
6062

6163
if not all_latest:

0 commit comments

Comments
 (0)