Temporary solution of the nav2_project python package compile with SetuptoolsDeprecationWarning

The following message is displayed when I compiling the “nav2_project” package:

user:~/ros2_ws$ colcon build
Starting >>> nav2_course
Starting >>> nav2_project
/usr/lib/python3/dist-packages/setuptools/dist.py:723: UserWarning: Usageof dash-separated 'script-dir' will not be supported in future versions. Please use the underscore name 'script_dir' instead
  warnings.warn(
/usr/lib/python3/dist-packages/setuptools/dist.py:723: UserWarning: Usageof dash-separated 'install-scripts' will not be supported in future versions. Please use the underscore name 'install_scripts' instead
  warnings.warn(
Finished <<< nav2_course [1.32s]
--- stderr: nav2_project
/usr/lib/python3/dist-packages/setuptools/dist.py:723: UserWarning: Usageof dash-separated 'script-dir' will not be supported in future versions. Please use the underscore name 'script_dir' instead
  warnings.warn(
/usr/lib/python3/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
---
Finished <<< nav2_project [2.05s]

Summary: 2 packages finished [4.32s]
  1 package had stderr output: nav2_project

According to the SetuptoolsDeprecationWarning, I searched the internet and found a blog describing the warning. However, I cannot confirm whether the reasons in the blog are accurate. Please refer to this link: Why you shouldn't invoke setup.py directly.

To addressed the warning, I tried the following steps to help me compile successfully the nav2_project

  1. Downgrade the setuptools version to 58.2.0:
    The following command can install setuptools with version 58.2.0
$ pip3 install setuptools==58.2.0
Defaulting to user installation because normal site-packages is not writeable
Collecting setuptools==58.2.0
  Using cached setuptools-58.2.0-py3-none-any.whl (946 kB)
Installing collected packages: setuptools
Successfully installed setuptools-58.2.0
  1. Replace the notation “-” with “_” within the “setup.cfg” file
    In this case, the “setup.cfg” file is within the “nav2_project” package.
|-- ros2_ws
|   |-- src
|   |   |-- nav2_project
|   |   |   |-- config
|   |   |   |-- launch
|   |   |   |-- nav2_project
|   |   |   |-- resource
|   |   |   |-- test
|   |   |   |-- package.xml
|   |   |   |-- setup.cfg
|   |   |   `-- setup.py

The original contents within the “setup.py” file are shown below:

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

I replaced the notation “-” with “_”, the contents after editing are shown below:

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

After tring these steps, the “nav2_project” compiled successfully:

user:~/ros2_ws$ colcon build
Starting >>> nav2_course
Starting >>> nav2_project
Finished <<< nav2_course [1.07s]
Finished <<< nav2_project [1.85s]

Summary: 2 packages finished [3.69s]

I am not sure if these are the correct steps but they can helped me complete:

  • Chapter 1: Introduction to ROS2 Navigation

If you have another views or solutions, please comment below to let me know :slight_smile:

Thank you.

1 Like

Hi there!

From my experience, if you encounter issues building a workspace for any reason, you can try deleting the old builds (the folders ‘build’, ‘log’, and ‘install’) in the workspace.

Anyway, solving an issue by diving into the code and project files is the best way to learn things in depth, so, well done!

1 Like

That problem of setuptools deprecation warning is very common in this version of the course and if you are using ament_python, it is caused because the simulator have installed an older version of setuptools, but this is a warning that doesn´t affect the package, you can compile and run the launch files without problems

1 Like

Refering to the setuptools reference,

Starting with PEP 621, the Python community selected pyproject.toml as a standard way of specifying project metadata . Setuptools has adopted this standard and will use the information contained in this file as an input in the build process.

which means setuptools newer than 58.2.0 will not support older standard of “setup.py” which ROS2 has incorporated in their python package hierarchy. So most safe and simple way imo is downgrading to 58.2.0 which you have already mentioned:

There are other ways to go around like using virtual env or even giving a blind eye as its just a depracation warning, it doesnt really affect our ROS2 python packages.

As you specified you wanted to get rid of SetuptoolsDeprecationWarning, the second solution wont do anything because its related only to UserWarnings to follow the newer naming standards. This solution will help you get rid of UserWarnings but again these are just deprecation warnings.

There’s an entire development chain which relies on the design of these dependent packages and if there are some changes required in design it will affect the entire chain hence developers and course creaters can get time to adapt to these design changes, As its the responsibilty of ROS package developers to incorporate the changes in the package system and responsiblity of platform developer to setup required versions of packages in the courses, you should not worry about these warnings, It doesnt affect the build outputs at all.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.