opencv-python: 4.8.0.74: `Exception: Not found: 'python/cv2/py.typed'` when building a contrib wheel with CUDA
Expected behaviour
Build a python-3.11 contrib wheel
Actual behaviour
Creating the wheel failed with this error:
Copying files from CMake output
creating directory _skbuild/linux-x86_64-3.11/cmake-install/cv2
copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/python-3/cv2.abi3.so -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/cv2.abi3.so
copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/__init__.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/__init__.py
copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/load_config_py2.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/load_config_py2.py
copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/load_config_py3.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/load_config_py3.py
copying _skbuild/linux-x86_64-3.11/cmake-install/python/cv2/config.py -> _skbuild/linux-x86_64-3.11/cmake-install/cv2/config.py
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 "/home/alex/T7/src/opencv-python/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/home/alex/T7/src/opencv-python/venv/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 "/home/alex/T7/src/opencv-python/venv/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 "/tmp/pip-build-env-mheswsk1/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 230, in build_wheel
return self._build_with_temp_dir(['bdist_wheel'], '.whl',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-mheswsk1/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 215, in _build_with_temp_dir
self.run_setup()
File "/tmp/pip-build-env-mheswsk1/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 268, in run_setup
self).run_setup(setup_script=setup_script)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-mheswsk1/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 158, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 532, in <module>
main()
File "setup.py", line 264, in main
skbuild.setup(
File "/tmp/pip-build-env-mheswsk1/overlay/lib/python3.11/site-packages/skbuild/setuptools_wrap.py", line 706, in setup
_classify_installed_files(
File "setup.py", line 445, in _classify_installed_files_override
raise Exception("Not found: '%s'" % relpath_re)
Exception: Not found: 'python/cv2/py.typed'
error: subprocess-exited-with-error
× Building wheel for opencv-contrib-python (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
full command: /home/alex/T7/src/opencv-python/venv/bin/python3.11 /home/alex/T7/src/opencv-python/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py build_wheel /tmp/tmpo050xxg7
cwd: /home/alex/T7/src/opencv-python
Building wheel for opencv-contrib-python (pyproject.toml) ... error
ERROR: Failed building wheel for opencv-contrib-python
Failed to build opencv-contrib-python
ERROR: Failed to build one or more wheels
Steps to reproduce
git clone https://github.com/opencv/opencv-python.git
cd opencv-python
git checkout tags/74 -b 4.8.0.74
git submodule update --init --recursive
python3.11 -m venv venv
source venv/bin/activate
pip install -U pip wheel
export CMAKE_ARGS="-DCMAKE_BUILD_TYPE=RELEASE -DWITH_CUDA=ON -DWITH_CUDNN=ON -DWITH_CUBLAS=ON -DWITH_TBB=ON -DOPENCV_DNN_CUDA=ON -DOPENCV_ENABLE_NONFREE=ON -DCUDA_ARCH_BIN=7.5 -DBUILD_EXAMPLES=OFF -DHAVE_opencv_python3=ON"
export ENABLE_CONTRIB=1
pip wheel . --verbose
The same scenario built fine with 4.7.0.72, I assume it is related to b534ea27a65acc766575bdface4abc984178eee8
- Ubuntu 22.04
- architecture amd64
- opencv-python 4.8.0.74
Issue submission checklist
-
This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 3
- Comments: 22
Commits related to this issue
- Merge pull request #24022 from VadimLevin:dev/vlevin/python-typing-cuda Fix python typing stubs generation for CUDA modules #24022 resolves #23946 resolves #23945 resolves opencv/opencv-python#8... — committed to opencv/opencv by VadimLevin a year ago
- Remove the type hint installation in setup.py https://github.com/opencv/opencv-python/issues/871#issuecomment-1698297467 — committed to hyliu1989/opencv-python-cuda by hyliu1989 8 months ago
- Merge pull request #24022 from VadimLevin:dev/vlevin/python-typing-cuda Fix python typing stubs generation for CUDA modules #24022 resolves #23946 resolves #23945 resolves opencv/opencv-python#8... — committed to thewoz/opencv by VadimLevin a year ago
Python type stubs are not generated by some reason. I reproduced the issue locally with python3.8. Looks like it’s somehow related to CUDA modules.
Apologies, I just realized that when I built my latest version I had
and on the .74 version I manually altered the build file not to check for the missing files.
You can check the full command line in Build Summary for my latest OpenCV python CUDA wheel.
Removing
and
from setup.py can compile a whl file with cudacodec. But frame_count from output video is negative. Related issue: https://github.com/opencv/opencv_contrib/issues/3556
Still has error while compiling, but still usable for final whl:
Related:
Indeed, disabling
cudacodec
andcudaoptflow
got the wheel built. Since it’s missingFarnebackOpticalFlow
I need, for now I just removed these lines fromsetup.py
: