opencv/opencv-python

Build problem with setuptools 75.6.0

thebaptiste opened this issue · 2 comments

Expected behaviour

I'm building with setuptools 75.6.0 on Python 3.12 with pip 24.2. I expect it works !

Actual behaviour

I have several problems when I build :

  • first a warning (just for the record) :
     /home/baptiste/mfext/build/opt/python3_scientific/lib/python3.12/site-packages/skbuild/command/test.py:3: SetuptoolsDeprecationWarning: The test command is disabled and references to it are deprecated.
      !!

              ********************************************************************************
              Please remove any references to `setuptools.command.test` in all supported versions of the affected package.

              This deprecation is overdue, please update your project and remove deprecated
              calls to avoid build errors in the future.
              ********************************************************************************

      !!
        from setuptools.command.test import test as _test
      /home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py:251: _IncompatibleBdistWheel: wheel.bdist_wheel is deprecated, please import it from setuptools
      !!

              ********************************************************************************
              Ensure that any custom bdist_wheel implementation is a subclass of
              setuptools.command.bdist_wheel.bdist_wheel.

              By 2025-Oct-15, you need to update your project and remove deprecated calls
              or your builds will no longer be supported.

              See https://github.com/pypa/wheel/pull/631 for details.
  • Then an error :
      copying LICENSE-3RD-PARTY.txt -> _skbuild/linux-x86_64-3.12/cmake-install/cv2/LICENSE-3RD-PARTY.txt
      Traceback (most recent call last):
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/_distutils/fancy_getopt.py", line 245, in getopt
          opts, args = getopt.getopt(args, short_opts, self.long_opts)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/getopt.py", line 93, in getopt
          opts, args = do_longs(opts, args[0][2:], longopts, args[1:])
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/getopt.py", line 157, in do_longs
          has_arg, opt = long_has_args(opt, longopts)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/getopt.py", line 174, in long_has_args
          raise GetoptError(_('option --%s not recognized') % opt, opt)
      getopt.GetoptError: option --dist-info-dir not recognized

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 170, in setup
          ok = dist.parse_command_line()
               ^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 472, in parse_command_line
          args = self._parse_command_opts(parser, args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/dist.py", line 896, in _parse_command_opts
          nargs = _Distribution._parse_command_opts(self, parser, args)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 576, in _parse_command_opts
          (args, opts) = parser.getopt(args[1:])
                         ^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/_distutils/fancy_getopt.py", line 247, in getopt
          raise DistutilsArgError(msg)
      distutils.errors.DistutilsArgError: option --dist-info-dir not recognized

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/build_meta.py", line 438, in build_wheel
          return _build(['bdist_wheel', '--dist-info-dir', str(metadata_directory)])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/build_meta.py", line 426, in _build
          return self._build_with_temp_dir(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/build_meta.py", line 407, in _build_with_temp_dir
          self.run_setup()
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/build_meta.py", line 522, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/build_meta.py", line 320, in run_setup
          exec(code, locals())
        File "<string>", line 543, in <module>
        File "<string>", line 273, in main
        File "/home/baptiste/mfext/build/opt/python3_scientific/lib/python3.12/site-packages/skbuild/setuptools_wrap.py", line 507, in setup
          return setuptools.setup(**kw)
                 ^^^^^^^^^^^^^^^^^^^^^^
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/__init__.py", line 117, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 172, in setup
          raise SystemExit(gen_usage(dist.script_name) + f"\nerror: {msg}")
      SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
         or: setup.py --help [cmd1 cmd2 ...]
         or: setup.py --help-commands
         or: setup.py cmd --help

      error: option --dist-info-dir not recognized

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/build_meta.py", line 444, in build_wheel
          return _build(['bdist_wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/build_meta.py", line 426, in _build
          return self._build_with_temp_dir(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/build_meta.py", line 407, in _build_with_temp_dir
          self.run_setup()
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/build_meta.py", line 522, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/home/baptiste/mfext/build/opt/python3_core/lib/python3.12/site-packages/setuptools/build_meta.py", line 320, in run_setup
          exec(code, locals())
        File "<string>", line 543, in <module>
        File "<string>", line 273, in main
        File "/home/baptiste/mfext/build/opt/python3_scientific/lib/python3.12/site-packages/skbuild/setuptools_wrap.py", line 671, in setup
          _classify_installed_files(
        File "<string>", line 483, in _classify_installed_files_override
      TypeError: RearrangeCMakeOutput._classify_installed_files_override() got an unexpected keyword argument '_cmake_install_dir'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for opencv-contrib-python-headless

I had no problem with setuptools 74.1.3. So it's probably linked to last changes in setuptools 75

Steps to reproduce

  • operating system : rockylinux 8
  • architecture : x86-64
  • opencv-python version : 4.10.0.84
Issue submission checklist
  • This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
  • I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
  • The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")
  • I'm using the latest version of opencv-python

I'm using wheel 0.41.3 and pip 24.2. I will try to upgrade them and let you know...

I made a few tests :

  • there was no problem with setuptools 75.0.0 and setuptools 75.1.0
  • the problem starts with setuptools 75.2.0. The root cause seems to be the "workaround" added in this release (take a look at the comments on this PR)
  • upgrading to wheel 0.45.1 fix the problem (see this PR)
  • nevertheless there is probably something to do in opencv in order to avoid to use deprecated stuff