in sagemaker_image_builder/utils.py [0:0]
def get_semver(version_str) -> Version:
# Version strings on conda-forge follow PEP standards rather than SemVer, which support
# version strings such as X.Y.Z.postN, X.Y.Z.preN. These cause errors in semver.Version.parse
# so we keep the first 3 entries as version string.
if version_str.count(".") > 2:
version_str = ".".join(version_str.split(".")[:3])
# If the version string doesn't include the patch version number, then assume it's 0.
if version_str.count(".") == 1:
version_str = f"{version_str}.0"
version = Version.parse(version_str)
if version.build is not None:
raise Exception()
return version