# This code is part of Qiskit.## (C) Copyright IBM 2017, 2021.## This code is licensed under the Apache License, Version 2.0. You may# obtain a copy of this license in the LICENSE.txt file in the root directory# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.## Any modifications or derivative works of this code must retain this# copyright notice, and modified files need to carry a notice indicating# that they have been altered from the originals.# pylint: disable-msg=import-error"""Reports a summary of information on Qiskit Metal and dependencies.Contain functions to report more detailed information to orient a user,used for debug purposes."""frompathlibimportPathfromtypingimportUnionimportosimportsysimportgetpassimportinspectimportplatformimportwebbrowserimportnumpyimportqutipfromqiskit_metal.toolbox_python.displayimportColor,style_colon_list__all__=['about','open_docs','orient_me','get_platform_info','get_module_doc_page']# pylint: disable-msg=invalid-name# pylint: disable-msg=import-outside-toplevel# pylint: disable-msg=bare-except
[docs]defabout():"""Reports a summary of information on Qiskit Metal and dependencies. Returns: str: About message """importqiskit_metalfromPySide6.QtCoreimport__version__asQT_VERSION_STRfromPySide6import__version__asPYSIDE_VERSION_STRtry:importmatplotlib#matplotlib_ver = matplotlib.__version__except:#matplotlib_ver = 'None'passtry:fromsipimportSIP_VERSION_STRexcept:SIP_VERSION_STR='Not installed'# Riverbank: SIP is a tool for quickly writing Python modules that interface with# C++ and C libraries.text=f"""Qiskit Metal {qiskit_metal.__version__}Basic____________________________________ Python {sys.version} Platform {platform.system()}{platform.machine()} Installation path {os.path.dirname(inspect.getsourcefile(qiskit_metal))}Packages____________________________________ Numpy {numpy.__version__} Qutip {qutip.__version__}Rendering____________________________________ Matplotlib {matplotlib.__version__}GUI____________________________________ PySide6 version {PYSIDE_VERSION_STR} Qt version {QT_VERSION_STR} SIP version {SIP_VERSION_STR}IBM Quantum Team"""print(text)returntext
[docs]defget_module_doc_page(module,folder=r'../docs/build/html',page='index.html'):"""Get the file path to a module doc folder assumed to be inside the package."""returnPath(os.path.dirname(module.__file__))/folder/page
[docs]defopen_docs(page='https://qiskit-community.github.io/qiskit-metal/'):"""Open the qiskit_metal documentation in HTML. Open the URL in new window, raising the window if possible. """webbrowser.open(page,new=1)####################################################################################### More detailed information to orient a user.# For debug purposes.# Main function: ``orient_me```#def orient_me(do_print: bool = True) -> Union[None, str]:"""Full system, python, user, and environemnt information. Args: do_print(bool): Return the string if True, else format and print. """
# text = get_platform_info()# text += \# f" User and directories:\n\n"\# f" User : {getpass.getuser()}\n"\# f" User home dirctry : {Path.home()}\n"\# f" Current directory : {Path.cwd()}\n\n"\# f" Conda default env : {os.environ.get('CONDA_DEFAULT_ENV', 'N/A')}\n"\# f" Conda current env : {os.environ.get('CONDA_PREFIX', 'N/A')}\n"\# f" Python executable : {sys.executable}\n"\# if do_print:# text = style_colon_list(text, Color.BOLD, Color.END)# print(text)# return None# return text
[docs]defget_platform_info()->str:"""Returns a string with the platform information."""return''' System platform information: system : %s node : %s release : %s machine : %s processor: %s summary : %s version : %s Python platform information: version : %s (implem: %s) compiler : %s'''%(platform.system(),platform.node(),platform.release(),platform.machine(),platform.processor(),platform.platform(),platform.version(),platform.python_version(),platform.python_implementation(),platform.python_compiler())