Skip to content
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: 0 additions & 1 deletion ros2cli/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<author email="michael.jeronimo@openrobotics.org">Michael Jeronimo</author>

<exec_depend>python3-argcomplete</exec_depend>
<exec_depend>python3-importlib-metadata</exec_depend>
<exec_depend>python3-packaging</exec_depend>
<exec_depend>python3-psutil</exec_depend>
<exec_depend>rclpy</exec_depend>
Expand Down
13 changes: 5 additions & 8 deletions ros2cli/ros2cli/entry_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@
# limitations under the License.

from collections import defaultdict
from importlib import metadata
import logging

try:
import importlib.metadata as importlib_metadata
except ModuleNotFoundError:
import importlib_metadata
import sys

"""
The group name for entry points identifying extension points.
Expand All @@ -44,7 +41,7 @@ def get_all_entry_points():

entry_points = defaultdict(dict)

for dist in importlib_metadata.distributions():
for dist in metadata.distributions():
for ep in dist.entry_points:
# skip groups which are not registered as extension points
if ep.group not in extension_points:
Expand All @@ -63,8 +60,8 @@ def get_entry_points(group_name):
to ``EntryPoint`` instances
:rtype: dict
"""
entry_points_impl = importlib_metadata.entry_points()
if hasattr(entry_points_impl, 'select'):
entry_points_impl = metadata.entry_points()
if sys.version_info >= (3, 12):
groups = entry_points_impl.select(group=group_name)
else:
groups = entry_points_impl.get(group_name, [])
Expand Down
1 change: 0 additions & 1 deletion ros2doctor/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<exec_depend>ament_index_python</exec_depend>
<exec_depend>python3-catkin-pkg-modules</exec_depend>
<exec_depend>python3-psutil</exec_depend>
<exec_depend>python3-importlib-metadata</exec_depend>
<exec_depend>python3-rosdistro-modules</exec_depend>
<exec_depend>rclpy</exec_depend>
<exec_depend>ros2cli</exec_depend>
Expand Down
15 changes: 6 additions & 9 deletions ros2doctor/ros2doctor/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from importlib import metadata
import sys
from typing import List
from typing import Set
from typing import Tuple

try:
import importlib.metadata as importlib_metadata
except ModuleNotFoundError:
import importlib_metadata

from ros2cli.node.strategy import NodeStrategy
from ros2doctor.api.format import doctor_warn

Expand Down Expand Up @@ -91,8 +88,8 @@ def run_checks(*, include_warnings=False, exclude_packages=False) -> Tuple[Set[s
fail_categories = set() # remove repeating elements
fail = 0
total = 0
entry_points = importlib_metadata.entry_points()
if hasattr(entry_points, 'select'):
entry_points = metadata.entry_points()
if sys.version_info >= (3, 12):
groups = entry_points.select(group='ros2doctor.checks')
else:
groups = entry_points.get('ros2doctor.checks', [])
Expand Down Expand Up @@ -130,8 +127,8 @@ def generate_reports(*, categories=None, exclude_packages=False) -> List[Report]
:return: list of Report objects
"""
reports = []
entry_points = importlib_metadata.entry_points()
if hasattr(entry_points, 'select'):
entry_points = metadata.entry_points()
if sys.version_info >= (3, 12):
groups = entry_points.select(group='ros2doctor.report')
else:
groups = entry_points.get('ros2doctor.report', [])
Expand Down
1 change: 0 additions & 1 deletion ros2pkg/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<exec_depend>ament_index_python</exec_depend>
<exec_depend>python3-catkin-pkg-modules</exec_depend>
<exec_depend>python3-empy</exec_depend>
<exec_depend>python3-importlib-resources</exec_depend>
<exec_depend>ros2cli</exec_depend>

<test_depend>ament_flake8</test_depend>
Expand Down
8 changes: 2 additions & 6 deletions ros2pkg/ros2pkg/api/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from importlib import resources
from io import StringIO
import os
import sys
Expand All @@ -23,11 +24,6 @@
except ImportError:
em_has_configuration = False

try:
import importlib.resources as importlib_resources
except ModuleNotFoundError:
import importlib_resources


def _expand_template(template_file, data, output_file):
output = StringIO()
Expand Down Expand Up @@ -87,7 +83,7 @@ def _create_template_file(
template_subdir, template_file_name, output_directory, output_file_name, template_config
):
full_package = 'ros2pkg.resource.' + template_subdir
with importlib_resources.path(full_package, template_file_name) as path:
with resources.path(full_package, template_file_name) as path:
template_path = str(path)
if not os.path.exists(template_path):
raise FileNotFoundError('template not found:', template_path)
Expand Down