Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 0 additions & 2 deletions .github/workflows/_Distribute-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ jobs:
WITH_TESTING: "ON"
WITH_INFERENCE_API_TEST: "OFF"
COVERALLS_UPLOAD: "ON"
PADDLE_VERSION: 0.0.0
CUDA_VISIBLE_DEVICES: 0,1
GIT_PR_ID: ${{ github.event.pull_request.number }}
GPUBOX_DEMO_INSTALL_DIR: /root/.cache/build
Expand Down Expand Up @@ -89,7 +88,6 @@ jobs:
-e WITH_TESTING \
-e COVERALLS_UPLOAD \
-e GIT_PR_ID \
-e PADDLE_VERSION \
-e WITH_DISTRIBUTE \
-e PY_VERSION \
-e WITH_TENSORRT \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/_Windows-GPU.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
runs-on:
group: win-gpu
env:
PADDLE_VERSION: 0.0.0
NIGHTLY_MODE: "OFF"
WITH_UNITY_BUILD: "ON"
WITH_TPCACHE: "ON"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/_Windows-Inference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
runs-on:
group: win-infer
env:
PADDLE_VERSION: 0.0.0
NIGHTLY_MODE: "OFF"
WITH_UNITY_BUILD: "ON"
WITH_TPCACHE: "ON"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/_Windows-OPENBLAS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
runs-on:
group: win-openblas
env:
PADDLE_VERSION: 0.0.0
NIGHTLY_MODE: "OFF"
WITH_UNITY_BUILD: "ON"
WITH_CACHE: "OFF"
Expand Down
65 changes: 5 additions & 60 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Get the latest git tag.
set(PADDLE_VERSION $ENV{PADDLE_VERSION})
if(WITH_NIGHTLY_BUILD)

if(NOT PADDLE_VERSION)
file(READ "${CMAKE_SOURCE_DIR}/version.txt" PADDLE_VERSION)
string(STRIP "${PADDLE_VERSION}" PADDLE_VERSION)
message(STATUS "Paddle version from version.txt: ${PADDLE_VERSION}")
execute_process(
COMMAND ${GIT_EXECUTABLE} show -s --format=%ci HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
Expand All @@ -12,65 +16,6 @@ if(WITH_NIGHTLY_BUILD)
message(STATUS "Last commit date: ${DATE_ONLY}")
set(PADDLE_VERSION "${PADDLE_VERSION}.dev${DATE_ONLY}")
endif()
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]+[0-9a-f]+[0-9a-f]+[0-9a-f]+[0-9a-f]+")
while("${PADDLE_VERSION}" STREQUAL "")
# Check current branch name
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref ${tmp_version}
WORKING_DIRECTORY ${PADDLE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH_NAME
RESULT_VARIABLE GIT_BRANCH_RESULT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT ${GIT_BRANCH_RESULT})
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 --always
${tmp_version}
WORKING_DIRECTORY ${PADDLE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_TAG_NAME
RESULT_VARIABLE GIT_RESULT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT ${GIT_RESULT})
# Check if current branch is release branch
if(${GIT_BRANCH_NAME} MATCHES "release/${TAG_VERSION_REGEX}")
# Check the tag is a correct version
if(${GIT_TAG_NAME} MATCHES "${COMMIT_VERSION_REGEX}")
# if no tag was found, set PADDLE_VERSION to 0.0.0 to represent latest
set(PADDLE_VERSION "0.0.0")
elseif(${GIT_TAG_NAME} MATCHES "v${TAG_VERSION_REGEX}")
string(REPLACE "v" "" PADDLE_VERSION ${GIT_TAG_NAME})
else() # otherwise, get the previous git tag name.
set(tmp_version "${GIT_TAG_NAME}~1")
endif()
else()
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --exact-match --tags ${tmp_version}
WORKING_DIRECTORY ${PADDLE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_EXACT_TAG_NAME
RESULT_VARIABLE GIT_EXACT_TAG_RESULT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT ${GIT_EXACT_TAG_NAME})
# Check if current branch is tag branch
if(${GIT_EXACT_TAG_NAME} MATCHES "v${TAG_VERSION_REGEX}")
string(REPLACE "v" "" PADDLE_VERSION ${GIT_EXACT_TAG_NAME})
else()
set(PADDLE_VERSION "0.0.0")
endif()
else()
# otherwise, we always set PADDLE_VERSION to 0.0.0 to represent latest
set(PADDLE_VERSION "0.0.0")
endif()
endif()
else()
set(PADDLE_VERSION "0.0.0")
message(WARNING "Cannot add paddle version from git tag")
endif()
else()
set(PADDLE_VERSION "0.0.0")
message(WARNING "Cannot add paddle version for wrong git branch result")
endif()
endwhile()

string(REPLACE "-" "." PADDLE_VER_LIST ${PADDLE_VERSION})
string(REPLACE "." ";" PADDLE_VER_LIST ${PADDLE_VER_LIST})
Expand Down
6 changes: 5 additions & 1 deletion python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,15 @@ def get_tensorrt_version() -> str:
print(f"Error while getting TensorRT version: {e}")
return None

def get_paddle_version() -> str:
return '@PADDLE_VERSION@'

def write_version_py(filename='paddle/version/__init__.py'):
cnt = '''# THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY
#
import inspect

full_version = '%(major)d.%(minor)d.%(patch)s'
full_version = '%(paddle_version)s'
major = '%(major)d'
minor = '%(minor)d'
patch = '%(patch)s'
Expand Down Expand Up @@ -502,6 +505,7 @@ def cuda_archs():

with open(filename, 'w') as f:
f.write(cnt % {
'paddle_version': get_paddle_version(),
'major': get_major(),
'minor': get_minor(),
'patch': get_patch(),
Expand Down
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,16 @@ def find_libnvinfer():
return None


def get_paddle_version() -> int:
return env_dict.get("PADDLE_VERSION")


def write_version_py(filename='paddle/version/__init__.py'):
cnt = '''# THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY
#
import inspect

full_version = '%(major)d.%(minor)d.%(patch)s'
full_version = '%(paddle_version)s'
major = '%(major)d'
minor = '%(minor)d'
patch = '%(patch)s'
Expand Down Expand Up @@ -824,6 +828,7 @@ def cuda_archs():
f.write(
cnt
% {
'paddle_version': get_paddle_version(),
'major': get_major(),
'minor': get_minor(),
'patch': get_patch(),
Expand Down
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3.0
Loading