Skip to content

Commit

Permalink
Add a script to check the pixi and rust environment dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Oct 24, 2024
1 parent 5770d58 commit e544609
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions scripts/check_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env python3

"""Checks that the dev environment is set up correctly."""

from __future__ import annotations

import subprocess

PIXI_VERSION = "0.34.0"
CARGO_VERSION = "1.79.0"
RUST_VERSION = "1.79.0"


def check_version(cmd: str, expected: str, update: str, install: str) -> bool:
try:
output = subprocess.check_output([cmd, "--version"])

version = output.strip().decode("utf-8").split(" ")[1]

if version != expected:
print(f"Expected {cmd} version {expected}, got {version}")
print(f"Please run `{update}`")
return False
else:
print(f"{cmd} version {version} is correct")
return True

except FileNotFoundError:
print(f"{cmd} not found in PATH. Please install via {install}")
return False


def main() -> int:
success = True

success &= check_version(
"pixi",
PIXI_VERSION,
f"pixi self-update --version {PIXI_VERSION}",
"https://pixi.sh/latest/",
)

success &= check_version(
"cargo",
CARGO_VERSION,
f"rustup install {CARGO_VERSION}",
"https://rustup.rs/",
)

success &= check_version(
"rustc",
RUST_VERSION,
f"rustup install {RUST_VERSION}",
"https://rustup.rs/",
)

if success:
exit(0)
else:
exit(1)


if __name__ == "__main__":
main()

0 comments on commit e544609

Please sign in to comment.