| 131 | |
| 132 | |
| 133 | def _strip_dev(version): |
| 134 | # First capturing group () is what we want to keep, at the beginning: |
| 135 | # |
| 136 | # - at least one numeral, then |
| 137 | # - repeats of {dot, at least one numeral} |
| 138 | # |
| 139 | # The rest (consume to the end of the string) is the stuff we want to cut |
| 140 | # off: |
| 141 | # |
| 142 | # - A period (maybe), then |
| 143 | # - "dev", "rc", or "+", then |
| 144 | # - numerals, periods, dashes, and "a" through "g" (hex chars) |
| 145 | # |
| 146 | # Thanks https://www.regextester.com ! |
| 147 | exp = r"^([0-9]+(?:\.[0-9]+)*)\.?(?:dev|rc|\+)[0-9+a-g\.\-]+$" |
| 148 | match = re.match(exp, version) |
| 149 | return match.groups()[0] if match is not None else version |
| 150 | |
| 151 | |
| 152 | def _require_version(lib, what, version="0.0"): |