- labscript_utils.versions.get_version(import_name, project_name=None, import_path=None)[source]¶
Try very hard to get the version of a package without importing it.
If import_path is not given, first find where it would be imported from, without importing it. Then look for metadata in the same import path with the given project name (note: this is not always the same as the import name, it is the name for example you would ask pip to install). If that is found, return the version info from it. Otherwise look for a
__version__.pyfile in the package directory, or a
__version__ = <version>literal defined in the package source (without executing it).
NotImplementedError – Raised if the module name contains a period. Only top-level packages are supported at this time.
The version literal of the package. If the package cannot be found,
NotFoundis returned. If the version cannot be obtained in the above way, or if the version was found but was