Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use catkin_pkg to parse packages #119

Merged
merged 2 commits into from
Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_index_python</buildtool_depend>
<buildtool_depend>python3-catkin-pkg-modules</buildtool_depend>
<buildtool_depend>rosidl_cmake</buildtool_depend>
<buildtool_depend>rosidl_parser</buildtool_depend>

Expand Down
22 changes: 2 additions & 20 deletions ros1_bridge/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import sys

import ament_index_python
from ament_package import parse_package
from catkin_pkg.package import parse_package
# ROS 1 imports
import genmsg
import genmsg.msg_loader
Expand All @@ -28,26 +28,8 @@

import yaml

# import catkin_pkg and rospkg which are required by rosmsg
# import rospkg which is required by rosmsg
# and likely only available for Python 2
try:
import catkin_pkg
except ImportError:
from importlib.machinery import SourceFileLoader
import subprocess
for python_executable in ['python2', 'python2.7']:
try:
catkin_pkg_path = subprocess.check_output(
[python_executable, '-c', 'import catkin_pkg; print(catkin_pkg.__file__)'])
except (subprocess.CalledProcessError, FileNotFoundError):
continue
catkin_pkg_path = catkin_pkg_path.decode().strip()
if catkin_pkg_path.endswith('.pyc'):
catkin_pkg_path = catkin_pkg_path[:-1]
catkin_pkg = SourceFileLoader('catkin_pkg', catkin_pkg_path).load_module()
if not catkin_pkg:
raise

try:
import rospkg
except ImportError:
Expand Down