labscript_utils.versions.check_version
- labscript_utils.versions.check_version(module_name, at_least, less_than, version=None, project_name=None)[source]
Checks if a module version is within specified bounds.
Checks that the version of the given module is at least and less than the given version strings. This function uses
get_version()
to determine version numbers without importing modules. In order to do this,project_name
must be provided if it differs frommodule_name
. For example, pyserial is imported as ‘serial’, but the project name, as passed to a ‘pip install’ command, is ‘pyserial’. Therefore to check the version of pyserial, pass inmodule_name='serial'
andproject_name='pyserial'
. You can also pass in a version string yourself, in which case no inspection of packages will take place.- Parameters:
module_name (str) – The name of the module to check.
at_least (str) – The minimum acceptable module version.
less_than (str) – The minimum unacceptable module version. Usually this would be the next major version if the package follows semver.
version (str, optional) – The current version of the installed package. Useful when the package version is stored in a non-standard location.
project_name (str, optional) – The package name (e.g. the name used when pip installing the package). This must be specified if it does not match the module name.
- Raises:
VersionException – if the module was not found or its version could not be determined.