【ROS 2】colcon buildでSetuptoolsDeprecationWarning: setup.py install is deprecatedと表示される問題の対処

ROS

概要

ROS 2のパッケージをcolcon buildでビルドした際に、以下のようなWarningが表示された際の原因や対処方法をメモします。

--- stderr: *******
/usr/lib/python3/dist-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
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(

環境

現象が発生した環境は以下の通りです。

  • Ubuntu 22.04 LTS
  • ROS 2 Humble
  • Python 3.10.12
  • setuptools 59.6.0

原因

Pythonのパッケージ管理ツールの一つであるeasy_installやsetup.pyを使用してのパッケージインストールが非推奨(deprecated)になったことに起因します。ROS 2のビルドシステムでsetup.pyを使ってインストールしていることが原因のように思われます。

以下が参考になりました。

SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. - ROS Answers: Open Source Q&A Forum
I am trying to create a package called helloworld that print out a message cd ~/ro2_ws/src ros2 pkg create --build-type ...
SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. · Issue #382 · ament/ament_cmake
SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. shows u...

対処

以下の対処方法が挙げられます。(ROS 2 IronやJazzy以降で対応されている可能性がありますが未確認です)

setuptoolsのダウングレード

setuptoolsを58.2.00に以下のコマンドでダウングレードする方法です。

pip3 install setuptools==58.2.00

特定のWarningを抑制

setuptoolsをダウングレードする場合は、推奨しないという方もいらっしゃるようで、特定のワーニングを抑制する方法が良いかもしれません。PYTHONWARNINGS環境変数で抑制する方法です。

以下に記載がある記事を紹介します。

SetuptoolsDeprecationWarning in ros2 Humble
I was trying to follow this tutorial in the official documentation of ros2 Humble for Integrating launch files into ROS ...

コメント