File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change 3
3
# SPDX-License-Identifier: Apache-2.0
4
4
5
5
6
+ import re
6
7
import sys
7
8
8
9
from setuptools import find_packages
35
36
"""
36
37
37
38
38
- def to_cmake_format (version ):
39
+ def to_cmake_format (version : str ):
39
40
"""Convert pep440 version string into a cmake compatible string."""
40
- version = version .strip ()
41
- parts = version .split ("+" )
42
- tag , dist = parts [0 ], parts [1 ].split ("." )[0 ]
43
- return tag + "." + dist
41
+ # cmake version just support up to 4 numbers separated by dot.
42
+ # https://peps.python.org/pep-0440/
43
+ # https://cmake.org/cmake/help/latest/command/project.html
44
+
45
+ match = re .search (r"^\d+(?:\.\d+(?:\.\d+(?:\.\d+)?)?)?" , version )
46
+ if not match :
47
+ raise Exception ("Unsupported version" )
48
+
49
+ return match .group (0 )
44
50
45
51
46
52
# Set is_install and is_develop flags
You can’t perform that action at this time.
0 commit comments