diff --git a/CMakeLists.txt b/CMakeLists.txt index 04366241a9..a2f33f4a36 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,11 +19,11 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") option(CMAKE_EXPORT_COMPILE_COMMANDS "Export compile command" ON) include(utils) -set_version(VERSION) +set_version(VERSION RELEASE) project(ortools VERSION ${VERSION} LANGUAGES CXX C) set(PROJECT_NAMESPACE ortools) -message(STATUS "${PROJECT_NAME} version: ${PROJECT_VERSION}") +message(STATUS "${PROJECT_NAME} version: ${PROJECT_VERSION} release: ${RELEASE}") #message(STATUS "major: ${PROJECT_VERSION_MAJOR}") #message(STATUS "minor: ${PROJECT_VERSION_MINOR}") #message(STATUS "patch: ${PROJECT_VERSION_PATCH}") diff --git a/cmake/python.cmake b/cmake/python.cmake index 6aa1796b0a..7e7dffe0ea 100644 --- a/cmake/python.cmake +++ b/cmake/python.cmake @@ -425,6 +425,11 @@ file(TOUCH ${PYTHON_PROJECT_DIR}/sat/python/py.typed) # setup.py.in contains cmake variable e.g. @PYTHON_PROJECT@ and # generator expression e.g. $ +if(RELEASE) + set(PYTHON_RELEASE "") +else() + set(PYTHON_RELEASE "rc1") +endif() configure_file( ${PROJECT_SOURCE_DIR}/ortools/python/setup.py.in ${PROJECT_BINARY_DIR}/python/setup.py.in diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 3168e03ceb..16ae090538 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -35,13 +35,14 @@ function(get_patch_from_git VERSION_PATCH VERSION_MAJOR) set(${VERSION_PATCH} ${PATCH} PARENT_SCOPE) endfunction() -function(set_version VERSION) +function(set_version VERSION RELEASE) if(DEFINED ENV{OR_TOOLS_MAJOR} AND DEFINED ENV{OR_TOOLS_MINOR}) set(MAJOR $ENV{OR_TOOLS_MAJOR}) set(MINOR $ENV{OR_TOOLS_MINOR}) else() # Get Major and Minor from Version.txt file(STRINGS "Version.txt" VERSION_STR) + set(IS_RELEASE TRUE) foreach(STR ${VERSION_STR}) if(${STR} MATCHES "OR_TOOLS_MAJOR=(.*)") set(MAJOR ${CMAKE_MATCH_1}) @@ -49,6 +50,9 @@ function(set_version VERSION) if(${STR} MATCHES "OR_TOOLS_MINOR=(.*)") set(MINOR ${CMAKE_MATCH_1}) endif() + if(${STR} MATCHES "^PRE_RELEASE=YES\$") + set(IS_RELEASE FALSE) + endif() endforeach() endif() @@ -64,6 +68,7 @@ function(set_version VERSION) endif() endif() set(${VERSION} "${MAJOR}.${MINOR}.${PATCH}" PARENT_SCOPE) + set(${RELEASE} ${IS_RELEASE} PARENT_SCOPE) endfunction() diff --git a/ortools/python/setup.py.in b/ortools/python/setup.py.in index 62362cc4bc..ce713f0950 100644 --- a/ortools/python/setup.py.in +++ b/ortools/python/setup.py.in @@ -39,7 +39,7 @@ def read(fname): setup( name='@PYTHON_PROJECT@', - version='@PROJECT_VERSION@', + version='@PROJECT_VERSION@@PYTHON_RELEASE@', packages=find_packages(), python_requires='>= 3.9', install_requires=[