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

entry_points install path is now 'bin' instead of 'lib' for setup.py installs #518

Closed
dustingooding opened this issue Jun 24, 2022 · 5 comments · Fixed by #520
Closed

entry_points install path is now 'bin' instead of 'lib' for setup.py installs #518

dustingooding opened this issue Jun 24, 2022 · 5 comments · Fixed by #520

Comments

@dustingooding
Copy link

dustingooding commented Jun 24, 2022

I believe a regression has been introduced with the merging of 5203c99 (or I'm holding something wrong).

With colcon-core at 0.9.0, the test_py_package fails to execute it's entry_points scripts.

I created a workspace, added the content of https://github.com/colcon/colcon-bundle/tree/master/integration/ros2_workspace/src/test_py_package to the workspace and built.

When executing the run_py_package_tests script, I get:

# ros2 run test_py_package run_py_package_tests
No executable found

The install space for the workspace looks like this:

# tree -L 3
.
├── COLCON_IGNORE
├── _local_setup_util_ps1.py
├── _local_setup_util_sh.py
├── local_setup.bash
├── local_setup.ps1
├── local_setup.sh
├── local_setup.zsh
├── setup.bash
├── setup.ps1
├── setup.sh
├── setup.zsh
└── test_py_package
    ├── bin
    │   └── run_py_package_tests
    ├── lib
    │   └── python3.8
    └── share
        ├── ament_index
        ├── colcon-core
        └── test_py_package

8 directories, 12 files

Previously, with colcon-core at 0.8.3, the run_py_package_tests executable was located in lib as a cousin to the python3.8 directory.

Downstream, this is causing other issues with things like launch files, with errors like "libexec directory '/path/to/workspace/
install/pkg_name/lib/pkg_name' does not exist"

@dustingooding dustingooding changed the title entry_points install path is now 'bin' instead of 'lib' for entry_points install path is now 'bin' instead of 'lib' for setup.py installs Jun 24, 2022
@devenpatel2
Copy link

devenpatel2 commented Jun 25, 2022

a workaround that seems to work for me is this

colcon build --symlink-install
colcon build

this creates the necessary directory in install/<package_name>/lib/<package_name>

@mr337
Copy link

mr337 commented Jun 27, 2022

a workaround that seems to work for me is this

colcon build --symlink-install
colcon build

this creates the necessary directory in install/<package_name>/lib/<package_name>

Was recently bit by this on our CICD pipeline as colcon-core 0.8.3 upgraded. Can confirm this work around is great.

@Guillaumebeuzeboc
Copy link

Faced the same issue.
In the setup.cfg I replaced

[develop]
script-dir=$base/lib/my_package
[install]
install-scripts=$base/lib/my_package

By

[develop]
script_dir=$base/lib/my_package
[install]
install_scripts=$base/lib/my_package

(so replacing dashes from variable's name by underscores)

@ralwing
Copy link

ralwing commented Nov 16, 2022

Yet another workaround is setting env variable:

SETUPTOOLS_USE_DISTUTILS=stdlib

Which will switch SETUPTOOLS to default system version included in installed python version.
https://github.com/pypa/setuptools/blob/main/CHANGES.rst#breaking-changes-5

Unfortunately, this workaround won't work soon.
And also will not work for Python >= 3.12

@jdiez17
Copy link

jdiez17 commented Oct 4, 2024

Hi, I'm still running into this problem.

My setup is as follows: I install colcon and dependencies into a Python 3.12 venv managed by uv, then run colcon build there. It looks like this:

ARG OVERLAY_WS=/home/rosdev/ros_ws_install
RUN mkdir -p $OVERLAY_WS
WORKDIR $OVERLAY_WS

RUN ~/.local/bin/uv venv --python 3.12 venv
RUN . ./venv/bin/activate && \
    ~/.local/bin/uv pip install git+https://github.com/colcon/colcon-cargo.git && \
    ~/.local/bin/uv pip install git+https://github.com/colcon/colcon-ros-cargo.git && \
    ~/.local/bin/uv pip install colcon-common-extensions

RUN . ./venv/bin/activate && \
    ~/.local/bin/uv pip install empy==3.3.4 # Workaround https://github.com/ros2/rosidl/issues/779 https://robotics.stackexchange.com/questions/109912/problem-with-building-nav2-on-ros-humble
RUN . ./venv/bin/activate && \
    ~/.local/bin/uv pip install lark numpy Cython

RUN --mount=type=bind,target=$OVERLAY_WS/src,source=./src \
    . /opt/ros/humble/setup.sh && \
    . ./venv/bin/activate && \
    touch venv/COLCON_IGNORE && \
    colcon build  \
      --event-handlers console_direct+ \
      --packages-up-to my_package

The console_scripts from my_package end up in install/lib/my_package/bin instead of lib.
The fix from #530 looks promising, and it works if I replace the underscores in my setup.cfg with dashes, looking like this:

[develop]
script-dir=$base/lib/my_package
[install]
install-scripts=$base/lib/my_package

I get the warning about script-dir being unsupported:

#20 15.54 running install_scripts
#20 15.93 Installing my_node script to /home/rosdev/ros_ws_install/install/my_package/lib/my_package
#20 16.14 !!
#20 16.14
#20 16.14         ********************************************************************************
#20 16.14         Usage of dash-separated 'script-dir' will not be supported in future
#20 16.14         versions. Please use the underscore name 'script_dir' instead.
#20 16.14
#20 16.14         This deprecation is overdue, please update your project and remove deprecated
#20 16.14         calls to avoid build errors in the future.
#20 16.14
#20 16.14         See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
#20 16.14         ********************************************************************************
#20 16.14
#20 16.14 !!
#20 16.14   opt = self.warn_dash_deprecation(opt, section)
#20 16.14 /home/rosdev/ros_ws_install/venv/lib/python3.12/site-packages/setuptools/_distutils/dist.py:261: UserWarning: Unknown distribution option: 'tests_require'
#20 16.14   warnings.warn(msg)

but it does install the script into the correct location.

@cottsay do you think it makes sense to also look for the install_scripts key in setup.cfg, or is there a better solution?

Note: ros2 pkg create --build-type ament_python creates a setup.cfg with script_dir and install_scripts keys.

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

Successfully merging a pull request may close this issue.

6 participants