Skip to content

Commit

Permalink
change method of getting version from setup.py to package.xml
Browse files Browse the repository at this point in the history
Signed-off-by: h-suzuki <h-suzuki@isp.co.jp>
  • Loading branch information
h-suzuki-isp committed Mar 5, 2024
1 parent c84d4dd commit b0efbf1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ros2caret/verb/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import re

from ros2caret.verb import VerbExtension
from ament_index_python.packages import get_package_share_directory


class CaretVersionVerb(VerbExtension):
Expand All @@ -25,9 +26,10 @@ def main(self, *, args):
print('v' + version)

def get_version(self):
version_path = f'{os.path.dirname(os.path.realpath(__file__))}/../../setup.py'
version_pattern = re.compile(r"\s*version\s*=\s*['\"](\d+\.\d+\.\d+)['\"]")
with open(version_path) as f:
dir_path = get_package_share_directory('ros2caret')
xml_path = os.path.join(dir_path, 'package.xml')
version_pattern = re.compile(r"\s*<version>\s*(\d+\.\d+\.\d+)\s*</version>\s*")
with open(xml_path) as f:
for line in f:
match = version_pattern.search(line)
if match:
Expand Down

0 comments on commit b0efbf1

Please sign in to comment.