MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / convert_version_to_int

Function convert_version_to_int

configure.py:437–459  ·  view source on GitHub ↗

Convert a version number to a integer that can be used to compare. Version strings of the form X.YZ and X.Y.Z-xxxxx are supported. The 'xxxxx' part, for instance 'homebrew' on OS/X, is ignored. Args: version: a version to be converted Returns: An integer if converted successfully,

(version)

Source from the content-addressed store, hash-verified

435
436
437def convert_version_to_int(version):
438 """Convert a version number to a integer that can be used to compare.
439
440 Version strings of the form X.YZ and X.Y.Z-xxxxx are supported. The
441 'xxxxx' part, for instance 'homebrew' on OS/X, is ignored.
442
443 Args:
444 version: a version to be converted
445
446 Returns:
447 An integer if converted successfully, otherwise return None.
448 """
449 version = version.split('-')[0]
450 version_segments = version.split('.')
451 # Treat "0.24" as "0.24.0"
452 if len(version_segments) == 2:
453 version_segments.append('0')
454 for seg in version_segments:
455 if not seg.isdigit():
456 return None
457
458 version_str = ''.join(['%03d' % int(seg) for seg in version_segments])
459 return int(version_str)
460
461
462def check_bazel_version(min_version, max_version):

Callers 3

check_bazel_versionFunction · 0.85
is_cuda_compatibleFunction · 0.85
mainFunction · 0.85

Calls 3

splitMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected