|
8 | 8 | from subprocess import DEVNULL, check_output |
9 | 9 |
|
10 | 10 | 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] |
13 | 12 |
|
14 | 13 | if sys.stdout.isatty() or os.environ.get("GITHUB_ACTIONS"): |
15 | 14 | GREEN, RED, RESET = "\033[92m", "\033[91m", "\033[0m" |
@@ -37,25 +36,28 @@ def python_check(item): |
37 | 36 | return False |
38 | 37 |
|
39 | 38 |
|
| 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 | + |
40 | 48 | def main(*packages): |
41 | 49 | all_latest = True |
42 | 50 | 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) |
48 | 52 | 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) |
54 | 56 | all_latest &= is_latest |
55 | 57 |
|
56 | 58 | text_color = GREEN if is_latest else RED |
57 | 59 | 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}" |
59 | 61 | ) |
60 | 62 |
|
61 | 63 | if not all_latest: |
|
0 commit comments