Open Corallo opened 1 year ago
OpenCV is written in C++ and uses CMake for project configuration. Python bindings utilize Python API for native modules and are generated as C++ code too. To get OpenCV on your system you need to install CMake tool first with apt-get install cmake
or with pip itself: pip install cmake
.
I've installed cmake with apt install cmake
and confirmed that I have the version 3.22.1, but during the build of the wheels, it still tries to build the wheels of numpy and cmake, failing to install cmake wheels.
The same happens when trying to install cmake with pip instead of apt.
Is there some flag that I need to set to make opencv notice that cmake is already installed and doesn't need to build the wheels for that? Couldn't find anyone with similar problem online.
The failure comes from a failed test:
107/654 Test #80: BundleUtilities .............................................***Failed 1.13 sec
that can't find a library:
/tmp/pip-install-brzg9mx2/cmake_1e02609438ab4f2faad2c0c0318a1081/_skbuild/linux-aarch64-3.10/cmake-build/CMakeProject-build/Tests/BundleUtilities/testdir1/testbundleutils1:
error while loading shared libraries: libshared.so: cannot open shared
object file: No such file or directory
Hello @Corallo. OpenCV pyproject.toml
includes cmake as dependency to ensure that all build per-requsites are there. Cmake team does not provide armv7 binary with pip (https://pypi.org/project/cmake/) and it's built automatically from sources. I have not found any other solution then just remove cmake from pyproject.toml
. It's not universal solution as it breaks all other platforms.
In this way installing cmake with apt-get will be enough?
I have tried to remove it from pyproject.toml, but doing so the build fails with a less clear error:
> [stage-1 37/37] RUN pip wheel .: [20/673]
Processing /code/opencv-python
Installing build dependencies: started
Installing build dependencies: still running...
installing build dependencies: still running...
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'error'
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [25 lines of output]
[present-rich] git submodule update --init --recursive opencv exited with 1
Traceback (most recent call last):
File "/root/.pyenv/versions/3.10.1/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
#0 165.9 main()
#0 165.9 File "/root/.pyenv/versions/3.10.1/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
#0 165.9 json_out['return_val'] = hook(**hook_input['kwargs'])
#0 165.9 File "/root/.pyenv/versions/3.10.1/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
#0 165.9 return hook(config_settings)
#0 165.9 File "/tmp/pip-build-env-1i1h1um3/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 162, in get_requires_for_build_wheel
#0 165.9 return self._get_build_requires(
#0 165.9 File "/tmp/pip-build-env-1i1h1um3/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 143, in _get_build_requires
#0 165.9 self.run_setup()
#0 165.9 File "/tmp/pip-build-env-1i1h1um3/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 267, in run_setup
#0 165.9 super(_BuildMetaLegacyBackend,
#0 165.9 File "/tmp/pip-build-env-1i1h1um3/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 158, in run_setup
#0 165.9 exec(compile(code, __file__, 'exec'), locals())
#0 165.9 File "setup.py", line 494, in <module>
#0 165.9 main()
#0 165.9 File "setup.py", line 49, in main
#0 165.9 g.run_command(
#0 165.9 File "/tmp/pip-build-env-1i1h1um3/overlay/lib/python3.10/site-packages/pip/_internal/vcs/versioncontrol.py", line 650, in run_command
#0 165.9 return call_subprocess(
#0 165.9 File "/tmp/pip-build-env-1i1h1um3/overlay/lib/python3.10/site-packages/pip/_internal/utils/subprocess.py", line 224, in call_subprocess
#0 165.9 raise error
#0 165.9 pip._internal.exceptions.InstallationSubprocessError: git submodule update --init --recursive opencv exited with 1
#0 165.9 [end of output]
#0 165.9
#0 165.9 note: This error originates from a subprocess, and is likely not a problem with pip.
#0 165.9 error: subprocess-exited-with-error
Is this how the pyproject.toml should look without cmake?
[build-system]
requires = [
"setuptools==59.2.0", "wheel==0.37.0", "pip",
"scikit-build>=0.13.2",
"numpy==1.13.3; python_version=='3.6' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
"numpy==1.17.0; python_version=='3.7' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
"numpy==1.17.3; python_version=='3.8' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
"numpy==1.19.3; python_version<='3.9' and sys_platform == 'linux' and platform_machine == 'aarch64'",
"numpy==1.21.0; python_version<='3.9' and sys_platform == 'darwin' and platform_machine == 'arm64'",
"numpy==1.19.3; python_version=='3.9' and platform_machine != 'aarch64' and platform_machine != 'arm64'",
"numpy==1.21.2; python_version=='3.10' and platform_system!='Darwin'",
"numpy==1.21.4; python_version=='3.10' and platform_system=='Darwin'",
"numpy==1.22.0; python_version>='3.11'"
]
M.b. related: https://github.com/opencv/opencv-python/pull/820
In case you need prebuilt opencv-python for raspberry pi: https://www.piwheels.org/project/opencv-python/
@sergregory Thank you, but I need to build the wheels by myself, because I need to apply a small patch to opencv before building, to add an extra video-source api.
Expected behaviour
I am trying to follow the instructions to build wheels for an armv7 device.
Actual behaviour
The build fails at the stage of building wheels for cmake
Do you have any suggestions on how to build wheels for armv7?
Steps to reproduce
Issue submission checklist
[x ] This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
[x ] 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)
[x ] 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