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

missing dependency on launch #2

Open
christianrauch opened this issue May 25, 2024 · 3 comments
Open

missing dependency on launch #2

christianrauch opened this issue May 25, 2024 · 3 comments
Labels
question Further information is requested

Comments

@christianrauch
Copy link

I am trying to run colcon lint, installed via pip install colcon-lint, with ros-tooling/setup-ros but it appears that the dependency on launch has not been defined, hence it is missing:

ERROR:colcon.colcon_core.extension_point:Exception loading extension 'colcon_core.verb.lint': No module named 'launch'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/colcon_core/extension_point.py", line 166, in load_extension_points
    extension_type = load_extension_point(name, value, group)
  File "/usr/lib/python3/dist-packages/colcon_core/extension_point.py", line 207, in load_extension_point
    return EntryPoint(name, value, group).load()
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/local/lib/python3.10/dist-packages/colcon_lint/verb/lint_depends.py", line 32, in <module>
    from launch.actions import DeclareLaunchArgument
ModuleNotFoundError: No module named 'launch'
@Tacha-S
Copy link
Owner

Tacha-S commented May 27, 2024

Thank you for your question.
Unfortunately, the launch package is not available on PYPI, so it cannot be added as a dependency during pip install.
Are you executing source /opt/ros/YOUR_DISTRO/setup.bash after running ros-tooling/setup-ros?

@Tacha-S Tacha-S added the question Further information is requested label May 27, 2024
@christianrauch
Copy link
Author

With Ubuntu 24.04 and PEP 668 the dependency management becomes a bit more difficult. It is now strongly recommended to use virtual environments to install packages via pip.

Installing colcon-lint in a virtual environment, which inherits the "system-site-packages":

python3 -m venv --system-site-packages ~/.venvs/dev
. ~/.venvs/dev/bin/activate
pip install colcon-lint

will not install the direct dependencies, such as colcon-core (from /usr/lib/python3/dist-packages), again. Hence, after sourcing:

. ~/.venvs/dev/bin/activate

the "system" colcon will then fail to find the lint verb.

Without --system-site-packages the directly provided dependencies, such as colcon-core, will be installed. But indirect dependencies, such as lark, will be missing and cause:

  File "/opt/ros/jazzy/lib/python3.12/site-packages/launch/frontend/parse_substitution.py", line 23, in <module>
    from lark import Lark
ModuleNotFoundError: No module named 'lark'

That means that all system dependencies in /usr/lib/python3/dist-packages have to be reinstalled in the virtual environment manually.

Do you have an idea how this can be resolved? Have you thought about adding the repo to the colcon organisation and create Debian packages, such as python3-colcon-clean for colcon-clean?

@Tacha-S
Copy link
Owner

Tacha-S commented Jun 3, 2024

Yes, I am also struggling with handling Ubuntu 24.04 and PEP 668.

That means that all system dependencies in /usr/lib/python3/dist-packages have to be reinstalled in the virtual environment manually.

If you just want to bypass the dependencies installed on the system like lark and make them usable, you could add the system's Python package path (e.g. /usr/lib/python3/dist-packages) to the sys.path (or PYTHONPATH) of the virtual environment. However, this is only a temporary measure.

Have you thought about adding the repo to the colcon organisation and create Debian packages, such as python3-colcon-clean for colcon-clean?

Transferring it to the colcon organization and making it installable via apt should make it easier to handle, so I plan to work on it when I have some time.

Nevertheless, it's still troubling that users cannot install and run colcon lint in a virtual environment according to PEP 668, but I'll set that aside for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants