MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / check_for_min_version

Function check_for_min_version

pymongo/common.py:1147–1162  ·  view source on GitHub ↗

Test whether an installed package is of the desired version.

(package_name: str)

Source from the content-addressed store, hash-verified

1145
1146
1147def check_for_min_version(package_name: str) -> tuple[str, str, bool]:
1148 """Test whether an installed package is of the desired version."""
1149 package_version_str = version(package_name)
1150 package_version = Version.from_string(package_version_str)
1151 # Dependency is expected to be in one of the forms:
1152 # "pymongocrypt<2.0.0,>=1.13.0; extra == 'encryption'"
1153 # 'dnspython<3.0.0,>=1.16.0'
1154 #
1155 requirements = requires("pymongo")
1156 assert requirements is not None
1157 requirement = [i for i in requirements if i.startswith(package_name)][0] # noqa: RUF015
1158 if ";" in requirement:
1159 requirement = requirement.split(";")[0]
1160 required_version = requirement[requirement.find(">=") + 2 :]
1161 is_valid = package_version >= Version.from_string(required_version)
1162 return package_version_str, required_version, is_valid

Callers 1

check_min_pymongocryptFunction · 0.90

Calls 2

from_stringMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected