提交 37a43221 编写于 作者: M minqiyang

Polish the code in setup.py.in

Change the PADDLE_VERSION in develop branch to latest
上级 add2e1b7
# Get the latest git tag. # Get the latest git tag.
set(PADDLE_VERSION $ENV{PADDLE_VERSION}) set(PADDLE_VERSION $ENV{PADDLE_VERSION})
set(tmp_version "HEAD") set(tmp_version "HEAD")
set(TAG_VERSION_REGEX "[0-9]+\\.[0-9]+\\.[0-9]+(\\.(a|b|rc)\\.[0-9]+)?")
set(COMMIT_VERSION_REGEX "[0-9a-f]{5,40}")
while ("${PADDLE_VERSION}" STREQUAL "") while ("${PADDLE_VERSION}" STREQUAL "")
execute_process( execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 ${tmp_version} COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 --always ${tmp_version}
WORKING_DIRECTORY ${PADDLE_SOURCE_DIR} WORKING_DIRECTORY ${PADDLE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_TAG_NAME OUTPUT_VARIABLE GIT_TAG_NAME
RESULT_VARIABLE GIT_RESULT RESULT_VARIABLE GIT_RESULT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT ${GIT_RESULT}) if (NOT ${GIT_RESULT})
# Check the tag is a correct version # Check the tag is a correct version
if (${GIT_TAG_NAME} MATCHES "v[0-9]+\\.[0-9]+\\.[0-9]+(\\.(a|b|rc)\\.[0-9]+)?") if (${GIT_TAG_NAME} MATCHES "${COMMIT_VERSION_REGEX}")
# if no tag was found, set PADDLE_VERSION to latest
set(PADDLE_VERSION "latest")
elseif (${GIT_TAG_NAME} MATCHES "v${VERSION_REGEX}")
string(REPLACE "v" "" PADDLE_VERSION ${GIT_TAG_NAME}) string(REPLACE "v" "" PADDLE_VERSION ${GIT_TAG_NAME})
else() # otherwise, get the previous git tag name. else() # otherwise, get the previous git tag name.
set(tmp_version "${GIT_TAG_NAME}~1") set(tmp_version "${GIT_TAG_NAME}~1")
......
...@@ -23,34 +23,22 @@ def _get_version_detail(idx): ...@@ -23,34 +23,22 @@ def _get_version_detail(idx):
assert idx < 3, "vesion info consists of %(major)d.%(minor)d.%(patch)d, \ assert idx < 3, "vesion info consists of %(major)d.%(minor)d.%(patch)d, \
so detail index must less than 3" so detail index must less than 3"
version_details = '@PADDLE_VERSION@'.split('.') if re.match('@TAG_VERSION_REGEX@', '@PADDLE_VERSION@'):
if len(version_details) == 3: version_details = '@PADDLE_VERSION@'.split('.')
detail = version_details[idx]
if re.match('[0-9]+', detail):
return int(detail)
return None if len(version_details) == 3:
return version_details[idx]
def get_major():
major = _get_version_detail(0)
if major is not None:
return major
return 'UNKNOWN' return 'UNKNOWN'
def get_minor(): def get_major():
minor = _get_version_detail(1) return _get_version_detail(0)
if minor is not None:
return minor
return 'UNKNOWN' def get_minor():
return _get_version_detail(1)
def get_patch(): def get_patch():
patch = _get_version_detail(2) return _get_version_detail(2)
if patch is not None:
return patch
return 'UNKNOWN'
def is_taged(): def is_taged():
try: try:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册