Skip to content

Commit

Permalink
json format to check qe is installed or not
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Sep 17, 2024
1 parent b9909ba commit c2ef7a3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/aiidalab_qe/setup/codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,18 @@ def get_qe_env():


def qe_installed():
import json

env_exist = get_qe_env().exists()
proc = subprocess.run(
["conda", "list", "-n", f"{get_qe_env().name}", "qe"],
["conda", "list", "-n", f"{get_qe_env().name}", "--json", "--full-name", "qe"],
check=True,
capture_output=True,
)

# XXX: "qe" in check is not future proof if there are similar packages such as qe-tool, better solution?? JSON output??
return env_exist and "qe" in str(proc.stdout)
info = json.loads(str(proc.stdout.decode()))[0]

return env_exist and "qe" == info["name"]


def install_qe():
Expand Down

0 comments on commit c2ef7a3

Please sign in to comment.