labscript_utils.versions.get_version
- 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__.py
file in the package directory, or a__version__ = <version>
literal defined in the package source (without executing it).- Parameters:
- Raises:
NotImplementedError – Raised if the module name contains a period. Only top-level packages are supported at this time.
- Returns:
The version literal of the package. If the package cannot be found,
NotFound
is returned. If the version cannot be obtained in the above way, or if the version was found but wasNone
,NoVersionInfo
is returned.