Skip to content

Commit

Permalink
make psi4 --version faster (psi4#3064)
Browse files Browse the repository at this point in the history
* Update run_psi4.py

* Update run_psi4.py
  • Loading branch information
loriab authored Oct 26, 2023
1 parent c6c6d7e commit df9a0dd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions psi4/run_psi4.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import datetime
import json
import os
import re
import sys
import warnings
from pathlib import Path
Expand Down Expand Up @@ -200,6 +201,12 @@
data_dir = os.path.abspath(os.path.expanduser(args["psidatadir"]))
os.environ["PSIDATADIR"] = data_dir

if args["version"]:
with (psi4_module_loc / "metadata.py").open() as fp: verline = fp.readline()
__version__ = re.match(r"__version__ = ['\"](?P<ver>.*)['\"]", verline).group("ver")
print(__version__)
sys.exit()

### Actually import psi4 and apply setup ###

# Arrange for warnings to ignore everything except the message
Expand All @@ -212,10 +219,6 @@ def custom_formatwarning(msg, *args, **kwargs):
sys.path.insert(1, lib_dir)
import psi4 # isort:skip

if args["version"]:
print(psi4.__version__)
sys.exit()

# Prevents a poor option combination
if args['plugin_template'] and (not args['plugin_name']):
raise KeyError("Please specify a '--plugin-name' for your plugin template!")
Expand Down

0 comments on commit df9a0dd

Please sign in to comment.