vcstool icon indicating copy to clipboard operation
vcstool copied to clipboard

vcstool is broken on Python 3.13

Open fferri opened this issue 1 year ago • 2 comments

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)

fferri avatar Nov 18 '24 17:11 fferri

@dirk-thomas, is there a plan to create an official release to replace the current 0.3.0 so that the deprecation doesn't lead to a 0.3.0 failure on the announced 2025-11-30?

Thank you.

rsarrazin2 avatar Sep 01 '25 11:09 rsarrazin2

@dirk-thomas, is there a plan to create an official release to replace the current 0.3.0 so that the deprecation doesn't lead to a 0.3.0 failure on the announced 2025-11-30?

Thank you.

See https://github.com/dirk-thomas/vcstool/issues/242 . TL;DR: A mantained friendly fork is available at https://github.com/ros-infrastructure/vcs2l .

traversaro avatar Sep 01 '25 13:09 traversaro