Skip to content

vcstool is broken on Python 3.13 #281

@fferri

Description

@fferri

e.g.:

❯ vcs import --input https://raw.githubusercontent.com/ros2/ros2/jazzy/ros2.repos src
Traceback (most recent call last):
  File "/opt/homebrew/bin/vcs", line 5, in <module>
    from vcstool.commands.vcs import main
  File "/opt/homebrew/lib/python3.13/site-packages/vcstool/commands/vcs.py", line 3, in <module>
    from vcstool.commands.help import get_entrypoint
  File "/opt/homebrew/lib/python3.13/site-packages/vcstool/commands/help.py", line 4, in <module>
    from pkg_resources import load_entry_point
  File "/opt/homebrew/lib/python3.13/site-packages/pkg_resources/__init__.py", line 2172, in <module>
    register_finder(pkgutil.ImpImporter, find_on_path)
                    ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?

it seems vcstool it is using deprecated pkg_resources (related: #269).

Solution:

make the following changes in vcstool/commands/help.py:

  1. change from pkg_resources import load_entry_point to from importlib.metadata import entry_points
  2. add following helper function:
def load_vcs_command(commands):
    entries = entry_points()
    vcs_entry_point = next(
        ep for ep in entries
        if ep.group == 'console_scripts' and ep.name == 'vcs-' + commands[0]
    )
    return vcs_entry_point.load()
  1. in function get_entrypoint(command), replace return load_entry_point(... with return load_vcs_command(commands)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions