Skip to content

Infer PADDLE_VERSION macro value from Git tag #42

@wangkuiyi

Description

@wangkuiyi

I noticed the following code snippet in /CMakeLists.txt file:

# add PaddlePaddle version
if(DEFINED ENV{PADDLE_VERSION})
    add_definitions(-DPADDLE_VERSION=\"$ENV{PADDLE_VERSION}\")
else()
    if(EXISTS ${PROJ_ROOT}/.svn/)
        find_package(Subversion REQUIRED)
        if(SUBVERSION_FOUND)
            Subversion_WC_INFO(${PROJ_ROOT} Project)
            add_definitions(-DPADDLE_VERSION=${Project_WC_REVISION})
        endif()
    endif()
endif()

It seems that the source code was managed by SVN, but migrated to Git later. So the idea of getting the PADDLE_VERSION macro value from .svn revision does no longer work.

I saw a workaround before above code snippet:

set(PADDLE_MAJOR_VERSION 0)
set(PADDLE_MINOR_VERSION 8)
set(PADDLE_PATCH_VERSION 0b)
set(PADDLE_VERSION ${PADDLE_MAJOR_VERSION}.${PADDLE_MINOR_VERSION}.${PADDLE_PATCH_VERSION})

To understand how the macro PADDLE_VERSION is used, I did:

$ for i in $(du -a | cut -f 2); do if [[ -f $i ]]; then if grep PADDLE_VERSION $i; then echo === $i ===; fi; fi; done
set(CPACK_PACKAGE_VERSION ${PADDLE_VERSION})
=== ./cmake/package.cmake ===
set(PADDLE_VERSION ${PADDLE_MAJOR_VERSION}.${PADDLE_MINOR_VERSION}.${PADDLE_PATCH_VERSION})
if(DEFINED ENV{PADDLE_VERSION})
    add_definitions(-DPADDLE_VERSION=\"$ENV{PADDLE_VERSION}\")
            add_definitions(-DPADDLE_VERSION=${Project_WC_REVISION})
=== ./CMakeLists.txt ===
        echo "PaddlePaddle @PADDLE_VERSION@, compiled with"
=== ./paddle/scripts/submit_local.sh.in ===
#ifndef PADDLE_VERSION
#define PADDLE_VERSION "unknown"
  os << "paddle version: " << PADDLE_VERSION << std::endl << std::boolalpha
=== ./paddle/utils/Version.cpp ===
      version='${PADDLE_VERSION}',
=== ./python/setup.py.in ===

It seems that PADDLE_VERSION is used some way, and it would be reasonable if we can infer its value from Git tags.

I confirm that we can find the tag we are on by running

git describe --tags --abbrev=0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions