gazebo-tooling / release-tools

8 stars 9 forks source link

detect_cmake_version.py: use raw regex strings #1133

Closed scpeters closed 5 months ago

scpeters commented 5 months ago

Some of the sequences in the regex patterns are not valid in python string literals (such as \(, so use raw strings instead (see related stack overflow answer). This fixes some SyntaxWarnings when running the script with python@3.12:

# without this script:
 ++ python3 detect_cmake_major_version.py /github/workspace/CMakeLists.txt
  /github/workspace/detect_cmake_major_version.py:15: SyntaxWarning: invalid escape sequence '\('
    old_version = re.search('set *\( *PROJECT_MAJOR_VERSION +(\d+)', txt)
  /github/workspace/detect_cmake_major_version.py:16: SyntaxWarning: invalid escape sequence '\('
    gazebo_version = re.search('set *\( *GAZEBO_MAJOR_VERSION +(\d+)', txt)
  /github/workspace/detect_cmake_major_version.py:17: SyntaxWarning: invalid escape sequence '\('
    sdformat_version = re.search('set *\( *SDF_MAJOR_VERSION +(\d+)', txt)
  /github/workspace/detect_cmake_major_version.py:18: SyntaxWarning: invalid escape sequence '\('
    ign_cmake_version = re.search('project *\( *ignition-[a-z\-_]+(\d+)', txt)
  /github/workspace/detect_cmake_major_version.py:19: SyntaxWarning: invalid escape sequence '\('
    cmake_project_version = re.search('project *\(.*VERSION +(\d+)', txt)
  + PACKAGE_MAJOR_VERSION=8