鱼香ROS社区
    • 版块
    • 最新
    • 未解决
    • 已解决
    • 群组
    • 注册
    • 登录
    紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
    提问前必看的发帖注意事项: 社区问答规则(小鱼个人)更新 | 高质量帖子发布指南

    build colcon 过程中遇到这样的问题怎么解决 setup.py

    已定时 已固定 已锁定 已移动
    ROS 2相关问题
    ros2 python ros2 colcon
    2
    7
    1.1k
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • L
      lvan-tan
      最后由 编辑

      /home/tan/.local/lib/python3.8/site-packages/setuptools/dist.py:495: SetuptoolsDeprecationWarning: Invalid dash-separated options
      !!

          ********************************************************************************
          Usage of dash-separated 'script-dir' will not be supported in future
          versions. Please use the underscore name 'script_dir' instead.
      
          By 2025-Mar-03, you need to update your project and remove deprecated calls
          or your builds will no longer be supported.
      
          See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
          ********************************************************************************
      

      !!
      opt = self.warn_dash_deprecation(opt, section)
      /home/tan/.local/lib/python3.8/site-packages/setuptools/dist.py:495: SetuptoolsDeprecationWarning: Invalid dash-separated options
      !!

          ********************************************************************************
          Usage of dash-separated 'install-scripts' will not be supported in future
          versions. Please use the underscore name 'install_scripts' instead.
      
          By 2025-Mar-03, you need to update your project and remove deprecated calls
          or your builds will no longer be supported.
      
          See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
          ********************************************************************************
      

      !!
      opt = self.warn_dash_deprecation(opt, section)

      1 条回复 最后回复 回复 引用 0
      • 小伊小
        机器人小伊
        最后由 编辑

        这个警告信息表明你在使用 setuptools 配置项目时,使用了即将被弃用的 dash-separated 选项(如 script-dir 和 install-scripts)。setuptools 正在转向使用 underscore 名称(如 script_dir 和 install_scripts)以提高配置的一致性和可预测性。

        为了解决这个问题,你需要更新你的 setup.py 文件,将所有的 dash-separated 选项替换为 underscore 名称。以下是具体步骤:

        1. 打开 setup.py 文件:
          找到你的项目的 setup.py 文件,并使用文本编辑器打开它。

        2. 查找并替换选项:
          在 setup.py 文件中,查找所有使用 dash-separated 选项的地方。例如,如果你看到类似 script-dir='some/path' 或 install-scripts='some/other/path' 的代码,你需要将它们替换为 script_dir='some/path' 和 install_scripts='some/other/path'。

        3. 保存并关闭文件:
          完成替换后,保存对 setup.py 文件的更改并关闭编辑器。

        4. 重新构建项目:
          回到你的命令行界面,重新运行 colcon build 或其他用于构建项目的命令,以确保更改生效且没有引入新的问题。

        5. 测试项目:
          构建完成后,确保你的项目仍然按预期工作。运行必要的测试来验证一切正常。

        通过遵循这些步骤,你可以解决由于使用即将被弃用的 dash-separated 选项而导致的警告,并确保你的项目与未来的 setuptools 版本兼容。此外,定期查看项目的依赖和工具链的更新日志和文档,可以帮助你及时发现并处理潜在的兼容性问题。


        以上为生成回答,仅供参考~

        我是小伊,已接入ChatGpt,所有回复,仅供参考~

        L 1 条回复 最后回复 回复 引用 0
        • L
          lvan-tan @小伊
          最后由 编辑

          @小伊 Starting >>> demo_cpp_pkg
          Starting >>> demo_python_pkg
          /home/tan/.local/lib/python3.8/site-packages/setuptools/_distutils/dist.py:261: UserWarning: Unknown distribution option: 'tests_require'
          warnings.warn(msg)
          Traceback (most recent call last):[demo_cpp_pkg:build - 0.4s] [demo_python_pkg - 0.4s]
          File "<string>", line 1, in <module>
          File "/home/tan/.local/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 275, in run_setup
          raise RuntimeError(
          RuntimeError: 'distutils.core.setup()' was never called -- perhaps 'setup.py' is not a Distutils setup script?
          --- stderr: demo_python_pkg
          Traceback (most recent call last):
          File "/usr/lib/python3/dist-packages/colcon_core/executor/init.py", line 91, in call
          rc = await self.task(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/colcon_core/task/init.py", line 93, in call
          return await task_method(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/colcon_ros/task/ament_python/build.py", line 51, in build
          setup_py_data = get_setup_data(self.context.pkg, env)
          File "/usr/lib/python3/dist-packages/colcon_core/task/python/init.py", line 20, in get_setup_data
          return dict(pkg.metadatakey)
          File "/usr/lib/python3/dist-packages/colcon_ros/package_augmentation/ros_ament_python.py", line 57, in getter
          return get_setup_information(
          File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 249, in get_setup_information
          _setup_information_cache[hashable_env] = _get_setup_information(
          File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 296, in get_setup_information
          result = subprocess.run(
          File "/usr/lib/python3.8/subprocess.py", line 516, in run
          raise CalledProcessError(retcode, process.args,
          subprocess.CalledProcessError: Command '['/usr/bin/python3', '-c', 'import sys;from contextlib import suppress;exec("with suppress(ImportError): from setuptools.extern.packaging.specifiers import SpecifierSet");exec("with suppress(ImportError): from packaging.specifiers import SpecifierSet");from distutils.core import run_setup;dist = run_setup( 'setup.py', script_args=('--dry-run',), stop_after='config');skip_keys = ('cmdclass', 'distclass', 'ext_modules', 'metadata');data = { key: value for key, value in dist.dict.items() if ( not key.startswith('
          ') and not callable(value) and key not in skip_keys and key not in dist.display_option_names )};data['metadata'] = { k: v for k, v in dist.metadata.dict.items() if k not in ('license_files', 'provides_extras')};sys.stdout.buffer.write(repr(data).encode('utf-8'))']' returned non-zero exit status 1.

          Failed <<< demo_python_pkg [0.50s, exited with code 1]
          Aborted <<< demo_cpp_pkg [0.51s]

          Summary: 0 packages finished [0.75s]
          1 package failed: demo_python_pkg
          1 package aborted: demo_cpp_pkg
          1 package had stderr output: demo_python_pkg
          Command '['/usr/bin/python3', '-c', 'import sys;from contextlib import suppress;exec("with suppress(ImportError): from setuptools.extern.packaging.specifiers import SpecifierSet");exec("with suppress(ImportError): from packaging.specifiers import SpecifierSet");from distutils.core import run_setup;dist = run_setup( 'setup.py', script_args=('--dry-run',), stop_after='config');skip_keys = ('cmdclass', 'distclass', 'ext_modules', 'metadata');data = { key: value for key, value in dist.dict.items() if ( not key.startswith('_') and not callable(value) and key not in skip_keys and key not in dist.display_option_names )};data['metadata'] = { k: v for k, v in dist.metadata.dict.items() if k not in ('license_files', 'provides_extras')};sys.stdout.buffer.write(repr(data).encode('utf-8'))']' returned non-zero exit status 1.

          1 条回复 最后回复 回复 引用 0
          • 小伊小
            机器人小伊
            最后由 编辑

            从错误信息来看,你在尝试构建两个包:demo_cpp_pkg 和 demo_python_pkg,其中 demo_python_pkg 遇到了问题。这里是一些关键的错误分析和可能的解决方案:

            1. Unknown distribution option: 'tests_require'

              • 这个警告提示 setup.py 文件中使用了 tests_require 选项,但这个选项在 setuptools 或 distutils 中不是标准选项。虽然这通常只会产生警告,不会导致构建失败,但最好检查你的 setup.py 文件,确认是否有必要使用这个选项,或者是否有其他方式指定测试依赖。
            2. RuntimeError: 'distutils.core.setup()' was never called

              • 这个错误表明 setup.py 脚本可能没有正确调用 setup() 函数,或者脚本结构有误。setup() 函数是必需的,用于配置包的安装信息。你需要检查 setup.py 文件,确保 setup() 函数被正确调用,并且格式正确。
            3. subprocess.CalledProcessError

              • 这个错误是由于尝试执行一个命令时返回了非零退出状态。从错误日志来看,这个命令是尝试执行一个 Python 脚本来解析 setup.py。这个错误通常意味着 setup.py 文件中有语法错误,或者其配置不符合预期。

            解决步骤

            1. 检查 setup.py 文件:

              • 确保 setup() 函数被正确调用。
              • 检查是否有语法错误。
              • 如果使用了 tests_require,考虑移除或替换为其他方式指定测试依赖。
            2. 清理环境:

              • 有时候,旧的构建文件或缓存可能会导致问题。尝试清理你的构建环境,比如删除 build、dist 和 .eggs 目录。
            3. 使用兼容的 Python 和 setuptools 版本:

              • 确保你使用的 Python 和 setuptools 版本与你的项目依赖兼容。
            4. 重新运行构建:

              • 在做了上述更改后,重新运行构建命令,看是否还有错误。

            如果问题仍然存在,你可能需要更详细地检查 setup.py 文件中的配置,或者查看是否有其他依赖或环境问题影响到构建过程。


            以上为生成回答,仅供参考~

            我是小伊,已接入ChatGpt,所有回复,仅供参考~

            L 1 条回复 最后回复 回复 引用 0
            • L
              lvan-tan
              最后由 编辑

              tan@ubuntu:~/chat2_cpp/chapt2_ws$ colcon build
              Starting >>> demo_cpp_pkg
              Starting >>> demo_python_pkg
              /home/tan/.local/lib/python3.8/site-packages/setuptools/_distutils/dist.py:261: UserWarning: Unknown distribution option: 'tests_require'
              warnings.warn(msg)
              Finished <<< demo_cpp_pkg [0.34s]
              --- stderr: demo_python_pkg
              /home/tan/.local/lib/python3.8/site-packages/setuptools/_distutils/dist.py:261: UserWarning: Unknown distribution option: 'tests_require'
              warnings.warn(msg)
              Traceback (most recent call last):
              File "setup.py", line 5, in <module>
              setup(
              File "/home/tan/.local/lib/python3.8/site-packages/setuptools/init.py", line 117, in setup
              return distutils.core.setup(**attrs)
              File "/home/tan/.local/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 183, in setup
              return run_commands(dist)
              File "/home/tan/.local/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 199, in run_commands
              dist.run_commands()
              File "/home/tan/.local/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 954, in run_commands
              self.run_command(cmd)
              File "/home/tan/.local/lib/python3.8/site-packages/setuptools/dist.py", line 999, in run_command
              super().run_command(command)
              File "/home/tan/.local/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 973, in run_command
              cmd_obj.run()
              File "/home/tan/.local/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 312, in run
              self.find_sources()
              File "/home/tan/.local/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 320, in find_sources
              mm.run()
              File "/home/tan/.local/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 546, in run
              self.prune_file_list()
              File "/home/tan/.local/lib/python3.8/site-packages/setuptools/command/sdist.py", line 162, in prune_file_list
              super().prune_file_list()
              File "/home/tan/.local/lib/python3.8/site-packages/setuptools/_distutils/command/sdist.py", line 380, in prune_file_list
              base_dir = self.distribution.get_fullname()
              File "/home/tan/.local/lib/python3.8/site-packages/setuptools/_core_metadata.py", line 267, in get_fullname
              return _distribution_fullname(self.get_name(), self.get_version())
              File "/home/tan/.local/lib/python3.8/site-packages/setuptools/_core_metadata.py", line 285, in _distribution_fullname
              canonicalize_version(version, strip_trailing_zero=False),
              TypeError: canonicalize_version() got an unexpected keyword argument 'strip_trailing_zero'

              Failed <<< demo_python_pkg [1.28s, exited with code 1]

              Summary: 1 package finished [1.46s]
              1 package failed: demo_python_pkg
              1 package had stderr output: demo_python_pkg

              1 条回复 最后回复 回复 引用 0
              • L
                lvan-tan @小伊
                最后由 编辑

                @小伊 Starting >>> demo_cpp_pkg
                Starting >>> demo_python_pkg
                /home/tan/.local/lib/python3.8/site-packages/setuptools/_distutils/dist.py:261: UserWarning: Unknown distribution option: 'tests_require'
                warnings.warn(msg)
                Finished <<< demo_cpp_pkg [0.35s]
                --- stderr: demo_python_pkg
                /home/tan/.local/lib/python3.8/site-packages/setuptools/_distutils/dist.py:261: UserWarning: Unknown distribution option: 'tests_require'
                warnings.warn(msg)
                Traceback (most recent call last):
                File "setup.py", line 5, in <module>
                setup(
                File "/home/tan/.local/lib/python3.8/site-packages/setuptools/init.py", line 117, in setup
                return distutils.core.setup(**attrs)
                File "/home/tan/.local/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 183, in setup
                return run_commands(dist)
                File "/home/tan/.local/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 199, in run_commands
                dist.run_commands()
                File "/home/tan/.local/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 954, in run_commands
                self.run_command(cmd)
                File "/home/tan/.local/lib/python3.8/site-packages/setuptools/dist.py", line 999, in run_command
                super().run_command(command)
                File "/home/tan/.local/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 973, in run_command
                cmd_obj.run()
                File "/home/tan/.local/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 312, in run
                self.find_sources()
                File "/home/tan/.local/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 320, in find_sources
                mm.run()
                File "/home/tan/.local/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 546, in run
                self.prune_file_list()
                File "/home/tan/.local/lib/python3.8/site-packages/setuptools/command/sdist.py", line 162, in prune_file_list
                super().prune_file_list()
                File "/home/tan/.local/lib/python3.8/site-packages/setuptools/_distutils/command/sdist.py", line 380, in prune_file_list
                base_dir = self.distribution.get_fullname()
                File "/home/tan/.local/lib/python3.8/site-packages/setuptools/_core_metadata.py", line 267, in get_fullname
                return _distribution_fullname(self.get_name(), self.get_version())
                File "/home/tan/.local/lib/python3.8/site-packages/setuptools/_core_metadata.py", line 285, in _distribution_fullname
                canonicalize_version(version, strip_trailing_zero=False),
                TypeError: canonicalize_version() got an unexpected keyword argument 'strip_trailing_zero'

                Failed <<< demo_python_pkg [1.25s, exited with code 1]

                Summary: 1 package finished [1.44s]
                1 package failed: demo_python_pkg
                1 package had stderr output: demo_python_pkg

                1 条回复 最后回复 回复 引用 0
                • 小伊小
                  机器人小伊
                  最后由 编辑

                  从您提供的日志信息来看,demo_python_pkg 这个 Python 包在构建过程中遇到了几个问题:

                  1. Unknown distribution option: 'tests_require':
                    这个警告表明 setup.py 文件中使用了 tests_require 这个选项,但这个选项不被当前的 setuptools 版本所识别。tests_require 通常用于指定运行测试所需的额外依赖,但在一些旧版本的 setuptools 中可能不被支持。如果您需要使用这个选项,可以考虑升级 setuptools 到最新版本。

                  2. TypeError: canonicalize_version() got an unexpected keyword argument 'strip_trailing_zero':
                    这个错误表明在调用 canonicalize_version() 函数时提供了一个不被接受的关键字参数 strip_trailing_zero。这通常是因为 setuptools 的版本与您的代码或依赖的某个库不兼容。这个问题可能由以下几种情况引起:

                    • setuptools 版本过旧或过新,不支持当前代码使用的某个特性。
                    • 代码中可能有对 setuptools 内部 API 的直接调用或依赖,而这些 API 在新版本中发生了变化。

                  解决建议:

                  1. 升级 setuptools:
                    尝试升级 setuptools 到最新版本,看是否解决问题。可以使用以下命令来升级:

                    pip install --upgrade setuptools
                    
                  2. 检查 setup.py:

                    • 如果不需要 tests_require,可以从 setup.py 中移除这个选项。
                    • 确保 setup.py 中没有使用到 setuptools 内部 API 或过时的参数。
                  3. 检查 setuptools 版本兼容性:

                    • 查看 demo_python_pkg 的依赖库是否有特定的 setuptools 版本要求。
                    • 如果可能,尝试使用与代码库兼容的特定版本的 setuptools。
                  4. 清理和重建:

                    • 清理任何之前构建的残留文件,如 .egg-info 目录。
                    • 重新运行构建命令。

                  如果上述步骤仍然无法解决问题,您可能需要检查更详细的构建日志,或者寻求特定库的社区支持。


                  以上为生成回答,仅供参考~

                  我是小伊,已接入ChatGpt,所有回复,仅供参考~

                  1 条回复 最后回复 回复 引用 0
                  • 第一个帖子
                    最后一个帖子
                  皖ICP备16016415号-7
                  Powered by NodeBB | 鱼香ROS