#-----------------------------------------------------------------------------# Copyright (c) Anaconda, Inc., and Bokeh Contributors.# All rights reserved.## The full license is in the file LICENSE.txt, distributed with this software.#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Boilerplate#-----------------------------------------------------------------------------from__future__importannotationsimportlogging# isort:skiplog=logging.getLogger(__name__)#-----------------------------------------------------------------------------# Imports#-----------------------------------------------------------------------------# Standard library importsimportplatformimportsys# Bokeh importsfrombokehimport__version__frombokeh.settingsimportsettingsfrombokeh.util.compilerimportnodejs_version,npmjs_versionfrombokeh.util.dependenciesimportimport_optional#-----------------------------------------------------------------------------# Globals and constants#-----------------------------------------------------------------------------__all__=("print_info",)#-----------------------------------------------------------------------------# General API#-----------------------------------------------------------------------------
[docs]defprint_info()->None:""" Print version information about Bokeh, Python, the operating system and a selected set of dependencies. """# Keep one print() per line, so that users don't have to wait a long# time for all libraries and dependencies to get loaded.newline='\n'print(f"Python version : {sys.version.split(newline)[0]}")print(f"IPython version : {_if_installed(_version('IPython','__version__'))}")print(f"Tornado version : {_if_installed(_version('tornado','version'))}")print(f"NumPy version : {_if_installed(_version('numpy','__version__'))}")print(f"Bokeh version : {__version__}")print(f"BokehJS static path : {settings.bokehjs_path()}")print(f"node.js version : {_if_installed(nodejs_version())}")print(f"npm version : {_if_installed(npmjs_version())}")print(f"jupyter_bokeh version : {_if_installed(_version('jupyter_bokeh','__version__'))}")print(f"Operating system : {platform.platform()}")
#-----------------------------------------------------------------------------# Legacy API#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Dev API#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Private API#-----------------------------------------------------------------------------def_if_installed(version_or_none:str|None)->str:""" Return the given version or not installed if ``None``. """returnversion_or_noneor"(not installed)"def_version(module_name:str,attr:str)->str|None:""" Get the version of a module if installed. """module=import_optional(module_name)returngetattr(module,attr)ifmoduleelseNone#-----------------------------------------------------------------------------# Code#-----------------------------------------------------------------------------