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 33# SPDX-License-Identifier: Apache-2.0
44
55
6+ import re
67import sys
78
89from setuptools import find_packages
3536"""
3637
3738
38- def to_cmake_format (version ):
39+ def to_cmake_format (version : str ):
3940 """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 )
4450
4551
4652# Set is_install and is_develop flags
You can’t perform that action at this time.
0 commit comments