nix-community / poetry2nix

Convert poetry projects to nix automagically [maintainer=@adisbladis,@cpcloud]
MIT License
836 stars 435 forks source link

opencv-python fails to build with Exception: Not found: 'python/cv2/py.typed' #1715

Open colonelpanic8 opened 2 months ago

colonelpanic8 commented 2 months ago

The full final traceback is this:

  copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/config-3.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/config-3.py
  Traceback (most recent call last):
    File "/nix/store/xhldz66b9bl8hwyhamx46wyyaklqr235-python3.11-pip-24.0/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/nix/store/xhldz66b9bl8hwyhamx46wyyaklqr235-python3.11-pip-24.0/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/nix/store/xhldz66b9bl8hwyhamx46wyyaklqr235-python3.11-pip-24.0/lib/python3.11/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 "/nix/store/g4h9138sa5wh6kkfwc7f49q169wcs8s9-python3.11-setuptools-69.5.1/lib/python3.11/site-packages/setuptools/build_meta.py", line 410, in build_wheel
      return self._build_with_temp_dir(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/nix/store/g4h9138sa5wh6kkfwc7f49q169wcs8s9-python3.11-setuptools-69.5.1/lib/python3.11/site-packages/setuptools/build_meta.py", line 395, in _build_with_temp_dir
      self.run_setup()
    File "/nix/store/g4h9138sa5wh6kkfwc7f49q169wcs8s9-python3.11-setuptools-69.5.1/lib/python3.11/site-packages/setuptools/build_meta.py", line 487, in run_setup
      super().run_setup(setup_script=setup_script)
    File "/nix/store/g4h9138sa5wh6kkfwc7f49q169wcs8s9-python3.11-setuptools-69.5.1/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup
      exec(code, locals())
    File "<string>", line 543, in <module>
    File "<string>", line 273, in main
    File "/nix/store/nll8byw5s6hqsaym2xkm8pbvhmiyff9i-python3.11-scikit-build-0.17.6/lib/python3.11/site-packages/skbuild/setuptools_wrap.py", line 707, in setup
      _classify_installed_files(
    File "<string>", line 456, in _classify_installed_files_override
  Exception: Not found: 'python/cv2/py.typed'

This is likely caused by an earlier failure that happens here:

  [473/1092] Generate files for Python bindings and documentation
  /build/opencv-python-4.10.0.84/opencv/modules/python/src2/typing_stubs_generator.py:52: UserWarning: Typing stubs generation has failed.
  Traceback (most recent call last):
    File "/build/opencv-python-4.10.0.84/opencv/modules/python/src2/typing_stubs_generation/nodes/type_node.py", line 291, in resolve
      self.value.resolve(root)
    File "/build/opencv-python-4.10.0.84/opencv/modules/python/src2/typing_stubs_generation/nodes/type_node.py", line 626, in resolve
      raise TypeResolutionError(
  typing_stubs_generation.nodes.type_node.TypeResolutionError: Failed to resolve one of "_typing.Union[cv2.typing.Scalar, GMat, GOpaqueT, GArrayT]" items. Errors: ['Failed to resolve "GMat" exposed as "GMat"', 'Failed to resolve "GOpaqueT" exposed as "GOpaqueT"', 'Failed to resolve "GArrayT" exposed as "GArrayT"']

  The above exception was the direct cause of the following exception:

  Traceback (most recent call last):
    File "/build/opencv-python-4.10.0.84/opencv/modules/python/src2/typing_stubs_generator.py", line 49, in wrapped_func
      ret_type = func(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^
    File "/build/opencv-python-4.10.0.84/opencv/modules/python/src2/typing_stubs_generator.py", line 148, in _generate
      generate_typing_stubs(self.cv_root, output_path)
    File "/build/opencv-python-4.10.0.84/opencv/modules/python/src2/typing_stubs_generation/generation.py", line 91, in generate_typing_stubs
      _generate_typing_module(root, output_path)
    File "/build/opencv-python-4.10.0.84/opencv/modules/python/src2/typing_stubs_generation/generation.py", line 794, in _generate_typing_module
      node.resolve(root)
    File "/build/opencv-python-4.10.0.84/opencv/modules/python/src2/typing_stubs_generation/nodes/type_node.py", line 293, in resolve
      raise TypeResolutionError(
  typing_stubs_generation.nodes.type_node.TypeResolutionError: Failed to resolve alias "GProtoArg" exposed as "GProtoArg"

    warnings.warn(
  Note: Class cv::Feature2D has more than 1 base class (not supported by Python C extensions)
        Bases:  cv::Algorithm, cv::class, cv::Feature2D, cv::Algorithm
        Only the first base class will be used
  Note: Class cv::detail::GraphCutSeamFinder has more than 1 base class (not supported by Python C extensions)
        Bases:  cv::detail::GraphCutSeamFinderBase, cv::detail::SeamFinder
        Only the first base class will be used
colonelpanic8 commented 2 months ago

This seems like it could be related: https://github.com/opencv/opencv-python/issues/913

colonelpanic8 commented 2 months ago

I also filed https://github.com/opencv/opencv-python/issues/1010