diff --git a/pyscf/gto/mole.py b/pyscf/gto/mole.py index ab1e32c61c..3caa803f6c 100644 --- a/pyscf/gto/mole.py +++ b/pyscf/gto/mole.py @@ -25,9 +25,7 @@ import sys import types import re -import platform import gc -import time import json import ctypes @@ -2695,7 +2693,6 @@ def gto_norm(self, l, expnt): def dump_input(self): import __main__ - import pyscf if hasattr(__main__, '__file__'): try: filename = os.path.abspath(__main__.__file__) @@ -2709,19 +2706,9 @@ def dump_input(self): except IOError: logger.warn(self, 'input file does not exist') - self.stdout.write('System: %s Threads %s\n' % - (str(platform.uname()), lib.num_threads())) - self.stdout.write('Python %s\n' % sys.version) - self.stdout.write('numpy %s scipy %s\n' % - (numpy.__version__, scipy.__version__)) - self.stdout.write('Date: %s\n' % time.ctime()) - self.stdout.write('PySCF version %s\n' % pyscf.__version__) - info = lib.repo_info(os.path.join(__file__, '..', '..')) - self.stdout.write('PySCF path %s\n' % info['path']) - if 'git' in info: - self.stdout.write(info['git'] + '\n') - - self.stdout.write('\n') + self.stdout.write('\n'.join(lib.misc.format_sys_info())) + + self.stdout.write('\n\n') for key in os.environ: if 'PYSCF' in key: self.stdout.write('[ENV] %s %s\n' % (key, os.environ[key])) diff --git a/pyscf/lib/misc.py b/pyscf/lib/misc.py index 1b109208dc..46ebf5edf0 100644 --- a/pyscf/lib/misc.py +++ b/pyscf/lib/misc.py @@ -22,6 +22,8 @@ import os import sys +import time +import platform import warnings import tempfile import functools @@ -30,6 +32,7 @@ import collections import ctypes import numpy +import scipy import h5py from threading import Thread from multiprocessing import Queue, Process @@ -1303,6 +1306,22 @@ def git_info(repo_path): pass return orig_head, head, branch +def format_sys_info(): + '''Format a list of system information for printing.''' + import pyscf + info = repo_info(os.path.join(__file__, '..', '..')) + result = [ + f'System: {platform.uname()} Threads {num_threads()}', + f'Python {sys.version}', + f'numpy {numpy.__version__} scipy {scipy.__version__}', + f'Date: {time.ctime()}', + f'PySCF version {pyscf.__version__}', + f'PySCF path {info["path"]}', + ] + if 'git' in info: + result.append(info['git']) + return result + def isinteger(obj): '''