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

Usage with bloom #31

Open
MrBlenny opened this issue Sep 15, 2022 · 1 comment
Open

Usage with bloom #31

MrBlenny opened this issue Sep 15, 2022 · 1 comment

Comments

@MrBlenny
Copy link

MrBlenny commented Sep 15, 2022

Hello. Thanks for putting the effort into this project. I think it will make a fantastic addition to ROS.

I was hoping to use this with bloom to include python deps in a .deb. I was going to include the pyproject.toml and optionally the poetry.lock in the deb (via setup.py data-files) and then run python3 -m colcon_poetry_ros.dependencies.install --install-base /opt/ros/galactic/share/* to install the deps using poetry. Ideally this would install them into a virtual environment or at least not the main site-packages (so different packages with different versions of the same library are supported).

I was going down this route as I have a bunch of packages with large dependencies such as pytorch and opencv which I don't want to package into the .debs

I got some of this working back in the day but had to disable virtual environments. I'm not very familiar with bloom or how ros launch would play with virtual envs but was hoping you might have an idea.

For example, the dpkg-query for a package bloomed with:

    data_files=[
        ("share/ament_index/resource_index/packages", ["resource/" + package_name]),
        ("share/" + package_name, ["package.xml", "pyproject.toml"]),
    ],

Looks something like:

$ dpkg-query -L ros-galactic-template-py-publisher
/.
/opt
/opt/ros
/opt/ros/galactic
/opt/ros/galactic/bin
/opt/ros/galactic/bin/publisher
/opt/ros/galactic/lib
/opt/ros/galactic/lib/python3.8
/opt/ros/galactic/lib/python3.8/site-packages
/opt/ros/galactic/lib/python3.8/site-packages/template_py_publisher
/opt/ros/galactic/lib/python3.8/site-packages/template_py_publisher/__init__.py
/opt/ros/galactic/lib/python3.8/site-packages/template_py_publisher/__pycache__
/opt/ros/galactic/lib/python3.8/site-packages/template_py_publisher/__pycache__/__init__.cpython-38.pyc
/opt/ros/galactic/lib/python3.8/site-packages/template_py_publisher/__pycache__/publisher.cpython-38.pyc
/opt/ros/galactic/lib/python3.8/site-packages/template_py_publisher/publisher.py
/opt/ros/galactic/lib/python3.8/site-packages/template_py_publisher-0.0.0.egg-info
/opt/ros/galactic/lib/python3.8/site-packages/template_py_publisher-0.0.0.egg-info/PKG-INFO
/opt/ros/galactic/lib/python3.8/site-packages/template_py_publisher-0.0.0.egg-info/dependency_links.txt
/opt/ros/galactic/lib/python3.8/site-packages/template_py_publisher-0.0.0.egg-info/entry_points.txt
/opt/ros/galactic/lib/python3.8/site-packages/template_py_publisher-0.0.0.egg-info/requires.txt
/opt/ros/galactic/lib/python3.8/site-packages/template_py_publisher-0.0.0.egg-info/top_level.txt
/opt/ros/galactic/lib/python3.8/site-packages/template_py_publisher-0.0.0.egg-info/zip-safe
/opt/ros/galactic/share
/opt/ros/galactic/share/ament_index
/opt/ros/galactic/share/ament_index/resource_index
/opt/ros/galactic/share/ament_index/resource_index/packages
/opt/ros/galactic/share/ament_index/resource_index/packages/template_py_publisher
/opt/ros/galactic/share/template_py_publisher
/opt/ros/galactic/share/template_py_publisher/package.xml
/opt/ros/galactic/share/template_py_publisher/pyproject.toml
/usr
/usr/share
/usr/share/doc
/usr/share/doc/ros-galactic-template-py-publisher
/usr/share/doc/ros-galactic-template-py-publisher/changelog.Debian.gz
/usr/share/doc/ros-galactic-template-py-publisher/copyright

Running install over this I get:

$ python3 -m colcon_poetry_ros.dependencies.install --base-path /opt/ros/galactic/share

The lock file does not exist. Locking.
Updating dependencies
Resolving dependencies... (0.1s)

[Errno 13] Permission denied: '/opt/ros/galactic/share/template_py_publisher/poetry.lock'
Traceback (most recent call last):
  File "/home/ros/.local/lib/python3.8/site-packages/colcon_poetry_ros/package.py", line 99, in get_requirements_txt
    subprocess.run(
  File "/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['poetry', 'export', '--format', 'requirements.txt', '--output', '/tmp/tmp4nmmji81']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/ros/.local/lib/python3.8/site-packages/colcon_poetry_ros/dependencies/install.py", line 179, in <module>
    main()
  File "/home/ros/.local/lib/python3.8/site-packages/colcon_poetry_ros/dependencies/install.py", line 22, in main
    _install_dependencies_via_pip(
  File "/home/ros/.local/lib/python3.8/site-packages/colcon_poetry_ros/dependencies/install.py", line 94, in _install_dependencies_via_pip
    requirements_data = project.get_requirements_txt([])
  File "/home/ros/.local/lib/python3.8/site-packages/colcon_poetry_ros/package.py", line 106, in get_requirements_txt
    raise RuntimeError(
RuntimeError: Failed to export Poetry dependencies in the requirements.txt format: Command '['poetry', 'export', '--format', 'requirements.txt', '--output', '/tmp/tmp4nmmji81']' returned non-zero exit status 1.

Even ignoring this permission issue - I imagine there will be problems. I could poetry shell && poetry install next to the pyproject.toml but I'm not sure how I'd tell launch which venv to use for which node.

I was wondering if anyone had any thoughts on how to get this working?

@velovix
Copy link
Member

velovix commented Sep 19, 2022

That's an interesting use case. I don't know very much about Bloom either. Combining ROS with virtual environments is a bit tricky, since workspaces are already a dependency isolation mechanism of sorts and they modify some of the same Python environment stuff that virtual environments do.

I believe roslaunch is extensible. Maybe an extension could be written to enter into a virtual environment before running a node?

Sorry that I can't be of more help. This is something I want to look into more as well.

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

No branches or pull requests

2 participants