Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cmake version convertion #1140

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-License-Identifier: Apache-2.0


import re
import sys

from setuptools import find_packages
Expand Down Expand Up @@ -35,12 +36,17 @@
"""


def to_cmake_format(version):
def to_cmake_format(version: str):
"""Convert pep440 version string into a cmake compatible string."""
version = version.strip()
parts = version.split("+")
tag, dist = parts[0], parts[1].split(".")[0]
return tag + "." + dist
# cmake version just support up to 4 numbers separated by dot.
# https://peps.python.org/pep-0440/
# https://cmake.org/cmake/help/latest/command/project.html

match = re.search(r"^\d+(?:\.\d+(?:\.\d+(?:\.\d+)?)?)?", version)
if not match:
raise Exception("Unsupported version")

return match.group(0)


# Set is_install and is_develop flags
Expand Down