Skip to content

Commit 0091f01

Browse files
authored
Refactor version management to use version.txt with date suffix for develop builds (#76314)
1 parent 58c6b9d commit 0091f01

File tree

10 files changed

+23
-67
lines changed

10 files changed

+23
-67
lines changed

.github/workflows/_Distribute-stable-Formers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
CACHE_DIR: /root/.cache/build
7373
CCACHE_DIR: /root/.ccache/formers
7474
CFS_DIR: /home/data/cfs
75-
paddle_whl: /workspace/dist/paddlepaddle_gpu-0.0.0-cp310-cp310-linux_x86_64.whl
75+
paddle_whl: /workspace/dist/*.whl
7676
formers_docker: ccr-2vdh3abv-pub.cnc.bj.baidubce.com/paddlepaddle/paddle:cuda126-dev-latest
7777
run: |
7878
export CUDA_SO="$(\ls -d /usr/lib64/libcuda* | xargs -I{} echo '-v {}:{}') $(\ls -d /usr/lib64/libnvidia* | xargs -I{} echo '-v {}:{}')"

.github/workflows/_Distribute-stable.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ jobs:
4949
WITH_TESTING: "ON"
5050
WITH_INFERENCE_API_TEST: "OFF"
5151
COVERALLS_UPLOAD: "ON"
52-
PADDLE_VERSION: 0.0.0
5352
CUDA_VISIBLE_DEVICES: 0,1
5453
GIT_PR_ID: ${{ github.event.pull_request.number }}
5554
GPUBOX_DEMO_INSTALL_DIR: /root/.cache/build
@@ -89,7 +88,6 @@ jobs:
8988
-e WITH_TESTING \
9089
-e COVERALLS_UPLOAD \
9190
-e GIT_PR_ID \
92-
-e PADDLE_VERSION \
9391
-e WITH_DISTRIBUTE \
9492
-e PY_VERSION \
9593
-e WITH_TENSORRT \
@@ -190,7 +188,7 @@ jobs:
190188
env:
191189
home_path: ${{ github.workspace }}/..
192190
bos_file: ${{ github.workspace }}/../bos_retry/BosClient.py
193-
paddle_whl: paddlepaddle_gpu-0.0.0-cp310-cp310-linux_x86_64.whl
191+
paddle_whl: "*.whl"
194192
run: |
195193
docker exec -t ${{ env.container_name }} /bin/bash -c '
196194
set -x

.github/workflows/_Windows-GPU.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
runs-on:
3636
group: win-gpu
3737
env:
38+
PADDLE_VERSION: 0.0.0
3839
NIGHTLY_MODE: "OFF"
3940
WITH_UNITY_BUILD: "ON"
4041
WITH_TPCACHE: "ON"

.github/workflows/_Windows-Inference.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
runs-on:
3636
group: win-infer
3737
env:
38+
PADDLE_VERSION: 0.0.0
3839
NIGHTLY_MODE: "OFF"
3940
WITH_UNITY_BUILD: "ON"
4041
WITH_TPCACHE: "ON"

.github/workflows/_Windows-OPENBLAS.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
runs-on:
3737
group: win-openblas
3838
env:
39+
PADDLE_VERSION: 0.0.0
3940
NIGHTLY_MODE: "OFF"
4041
WITH_UNITY_BUILD: "ON"
4142
WITH_CACHE: "OFF"

ci/distribute_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
148148
pip install onnx==1.17.0
149149
pip install -r "${work_dir}/python/requirements.txt"
150150
pip install -r "${work_dir}/python/unittest_py/requirements.txt"
151-
pip install --force-reinstall ${work_dir}/dist/paddlepaddle_gpu-0.0.0-cp310-cp310-linux_x86_64.whl --no-deps
151+
pip install --force-reinstall ${work_dir}/dist/*.whl --no-deps
152152
echo "::endgroup::"
153153
ldconfig
154154

cmake/version.cmake

Lines changed: 5 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Get the latest git tag.
22
set(PADDLE_VERSION $ENV{PADDLE_VERSION})
3-
if(WITH_NIGHTLY_BUILD)
3+
4+
if(NOT PADDLE_VERSION)
5+
file(READ "${CMAKE_SOURCE_DIR}/version.txt" PADDLE_VERSION)
6+
string(STRIP "${PADDLE_VERSION}" PADDLE_VERSION)
7+
message(STATUS "Paddle version from version.txt: ${PADDLE_VERSION}")
48
execute_process(
59
COMMAND ${GIT_EXECUTABLE} show -s --format=%ci HEAD
610
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
@@ -12,65 +16,6 @@ if(WITH_NIGHTLY_BUILD)
1216
message(STATUS "Last commit date: ${DATE_ONLY}")
1317
set(PADDLE_VERSION "${PADDLE_VERSION}.dev${DATE_ONLY}")
1418
endif()
15-
set(tmp_version "HEAD")
16-
set(TAG_VERSION_REGEX "[0-9]+\\.[0-9]+\\.[0-9]+(\\.(a|b|rc)\\.[0-9]+)?")
17-
set(COMMIT_VERSION_REGEX "[0-9a-f]+[0-9a-f]+[0-9a-f]+[0-9a-f]+[0-9a-f]+")
18-
while("${PADDLE_VERSION}" STREQUAL "")
19-
# Check current branch name
20-
execute_process(
21-
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref ${tmp_version}
22-
WORKING_DIRECTORY ${PADDLE_SOURCE_DIR}
23-
OUTPUT_VARIABLE GIT_BRANCH_NAME
24-
RESULT_VARIABLE GIT_BRANCH_RESULT
25-
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
26-
if(NOT ${GIT_BRANCH_RESULT})
27-
execute_process(
28-
COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=0 --always
29-
${tmp_version}
30-
WORKING_DIRECTORY ${PADDLE_SOURCE_DIR}
31-
OUTPUT_VARIABLE GIT_TAG_NAME
32-
RESULT_VARIABLE GIT_RESULT
33-
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
34-
if(NOT ${GIT_RESULT})
35-
# Check if current branch is release branch
36-
if(${GIT_BRANCH_NAME} MATCHES "release/${TAG_VERSION_REGEX}")
37-
# Check the tag is a correct version
38-
if(${GIT_TAG_NAME} MATCHES "${COMMIT_VERSION_REGEX}")
39-
# if no tag was found, set PADDLE_VERSION to 0.0.0 to represent latest
40-
set(PADDLE_VERSION "0.0.0")
41-
elseif(${GIT_TAG_NAME} MATCHES "v${TAG_VERSION_REGEX}")
42-
string(REPLACE "v" "" PADDLE_VERSION ${GIT_TAG_NAME})
43-
else() # otherwise, get the previous git tag name.
44-
set(tmp_version "${GIT_TAG_NAME}~1")
45-
endif()
46-
else()
47-
execute_process(
48-
COMMAND ${GIT_EXECUTABLE} describe --exact-match --tags ${tmp_version}
49-
WORKING_DIRECTORY ${PADDLE_SOURCE_DIR}
50-
OUTPUT_VARIABLE GIT_EXACT_TAG_NAME
51-
RESULT_VARIABLE GIT_EXACT_TAG_RESULT
52-
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
53-
if(NOT ${GIT_EXACT_TAG_NAME})
54-
# Check if current branch is tag branch
55-
if(${GIT_EXACT_TAG_NAME} MATCHES "v${TAG_VERSION_REGEX}")
56-
string(REPLACE "v" "" PADDLE_VERSION ${GIT_EXACT_TAG_NAME})
57-
else()
58-
set(PADDLE_VERSION "0.0.0")
59-
endif()
60-
else()
61-
# otherwise, we always set PADDLE_VERSION to 0.0.0 to represent latest
62-
set(PADDLE_VERSION "0.0.0")
63-
endif()
64-
endif()
65-
else()
66-
set(PADDLE_VERSION "0.0.0")
67-
message(WARNING "Cannot add paddle version from git tag")
68-
endif()
69-
else()
70-
set(PADDLE_VERSION "0.0.0")
71-
message(WARNING "Cannot add paddle version for wrong git branch result")
72-
endif()
73-
endwhile()
7419

7520
string(REPLACE "-" "." PADDLE_VER_LIST ${PADDLE_VERSION})
7621
string(REPLACE "." ";" PADDLE_VER_LIST ${PADDLE_VER_LIST})

python/setup.py.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,15 @@ def get_tensorrt_version() -> str:
176176
print(f"Error while getting TensorRT version: {e}")
177177
return None
178178

179+
def get_paddle_version() -> str:
180+
return '@PADDLE_VERSION@'
181+
179182
def write_version_py(filename='paddle/version/__init__.py'):
180183
cnt = '''# THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY
181184
#
182185
import inspect
183186

184-
full_version = '%(major)d.%(minor)d.%(patch)s'
187+
full_version = '%(paddle_version)s'
185188
major = '%(major)d'
186189
minor = '%(minor)d'
187190
patch = '%(patch)s'
@@ -502,6 +505,7 @@ def cuda_archs():
502505

503506
with open(filename, 'w') as f:
504507
f.write(cnt % {
508+
'paddle_version': get_paddle_version(),
505509
'major': get_major(),
506510
'minor': get_minor(),
507511
'patch': get_patch(),

setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,12 +497,16 @@ def find_libnvinfer():
497497
return None
498498

499499

500+
def get_paddle_version() -> int:
501+
return env_dict.get("PADDLE_VERSION")
502+
503+
500504
def write_version_py(filename='paddle/version/__init__.py'):
501505
cnt = '''# THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY
502506
#
503507
import inspect
504508
505-
full_version = '%(major)d.%(minor)d.%(patch)s'
509+
full_version = '%(paddle_version)s'
506510
major = '%(major)d'
507511
minor = '%(minor)d'
508512
patch = '%(patch)s'
@@ -824,6 +828,7 @@ def cuda_archs():
824828
f.write(
825829
cnt
826830
% {
831+
'paddle_version': get_paddle_version(),
827832
'major': get_major(),
828833
'minor': get_minor(),
829834
'patch': get_patch(),

version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.3.0

0 commit comments

Comments
 (0)