opencv-python icon indicating copy to clipboard operation
opencv-python copied to clipboard

Failed to compile opencv-python in python:3.10-+alpine image today which usually success previously

Open hteeyeoh opened this issue 8 months ago • 3 comments

Expected behaviour

Successfully install opencv-python as usual in python:3.10-alpine image as usual

Actual behaviour

Compilation failed

Steps to reproduce

pip install opencv-python in python:3.10 alpine image

- opencv-python = opencv-python==4.6.0.66

62.48       ninja: job failed: /usr/bin/c++  -I/tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ippicv/ippicv_lnx/icv/include -I/tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ippicv/ippicv_lnx/iw/include -I/tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/include -isystem /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -Wno-long-long -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections  -msse -msse2 -msse3 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG -std=c++11 -fPIC -MD -MT CMakeFiles/ade.dir/3rdparty/ade/ade-0.1.1f/sources/ade/source/topological_sort.cpp.o -MF CMakeFiles/ade.dir/3rdparty/ade/ade-0.1.1f/sources/ade/source/topological_sort.cpp.o.d -o CMakeFiles/ade.dir/3rdparty/ade/ade-0.1.1f/sources/ade/source/topological_sort.cpp.o -c /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/source/topological_sort.cpp
62.48       In file included from /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/include/ade/passes/topological_sort.hpp:17,
62.48                        from /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/source/topological_sort.cpp:7:
62.48       /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/include/ade/typed_graph.hpp:101:10: error: 'uintptr_t' in namespace 'std' does not name a type
62.48         101 |     std::uintptr_t m_srcGraph;
62.48             |          ^~~~~~~~~
62.48       /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/include/ade/typed_graph.hpp:22:1: note: 'std::uintptr_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
62.48          21 | #include "typed_metadata.hpp"
62.48         +++ |+#include <cstdint>
62.48          22 |
62.48       /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/include/ade/typed_graph.hpp: In member function 'const ade::Graph& ade::ConstTypedGraph<Types>::getCGraph() const':
62.48       /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/include/ade/typed_graph.hpp:106:53: error: 'm_srcGraph' was not declared in this scope
62.48         106 |         return *reinterpret_cast<const ade::Graph*>(m_srcGraph);
62.48             |                                                     ^~~~~~~~~~
62.48       /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/include/ade/typed_graph.hpp: In constructor 'ade::ConstTypedGraph<Types>::ConstTypedGraph(const ade::Graph&)':
62.48       /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/include/ade/typed_graph.hpp:122:9: error: class 'ade::ConstTypedGraph<Types>' does not have any field named 'm_srcGraph'
62.48         122 |         m_srcGraph(reinterpret_cast<std::uintptr_t>(&graph))
62.48             |         ^~~~~~~~~~
62.48       /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/include/ade/typed_graph.hpp:122:42: error: 'uintptr_t' in namespace 'std' does not name a type
62.48         122 |         m_srcGraph(reinterpret_cast<std::uintptr_t>(&graph))
62.48             |                                          ^~~~~~~~~
62.48       /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/include/ade/typed_graph.hpp:122:37: note: 'std::uintptr_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
62.48         122 |         m_srcGraph(reinterpret_cast<std::uintptr_t>(&graph))
62.48             |                                     ^~~
62.48       /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/include/ade/typed_graph.hpp: In constructor 'ade::ConstTypedGraph<Types>::ConstTypedGraph(const ade::ConstTypedGraph<OtherTypes ...>&)':
62.48       /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/include/ade/typed_graph.hpp:130:9: error: class 'ade::ConstTypedGraph<Types>' does not have any field named 'm_srcGraph'
62.48         130 |         m_srcGraph(other.m_srcGraph)
62.48             |         ^~~~~~~~~~
62.48       /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/include/ade/typed_graph.hpp: In instantiation of 'ade::Graph& ade::TypedGraph<Types>::getGraph() const [with Types = {ade::passes::TopologicalSortData}]':
62.48       /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/include/ade/typed_graph.hpp:238:16:   required from 'ade::Graph::NodesListRange ade::TypedGraph<Types>::nodes() [with Types = {ade::passes::TopologicalSortData}; ade::Graph::NodesListRange = ade::util::Range::MapRange<ade::util::Range::IterRange<__gnu_cxx::__normal_iterator<std::shared_ptr<ade::Node>*, std::vector<std::shared_ptr<ade::Node> > > >, ade::Graph::HandleMapper>]'
62.48       /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/source/topological_sort.cpp:39:40:   required from here
62.48       /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/include/ade/typed_graph.hpp:167:53: error: 'const class ade::TypedGraph<ade::passes::TopologicalSortData>' has no member named 'm_srcGraph'
62.48         167 |         return *reinterpret_cast<ade::Graph*>(this->m_srcGraph);
62.48             |                                               ~~~~~~^~~~~~~~~~
62.48       Note: Class cv::Feature2D has more than 1 base class (not supported by Python C extensions)
62.48             Bases:  cv::Algorithm, cv::class, cv::Feature2D, cv::Algorithm
62.48             Only the first base class will be used
62.48       Note: Class cv::detail::GraphCutSeamFinder has more than 1 base class (not supported by Python C extensions)
62.48             Bases:  cv::detail::GraphCutSeamFinderBase, cv::detail::SeamFinder
62.48             Only the first base class will be used
62.48       ninja: subcommand failed
62.48       Traceback (most recent call last):
62.48         File "/tmp/pip-build-env-z3sx64lf/overlay/lib/python3.10/site-packages/skbuild/setuptools_wrap.py", line 674, in setup
62.48           cmkr.make(make_args, install_target=cmake_install_target, env=env)
62.48         File "/tmp/pip-build-env-z3sx64lf/overlay/lib/python3.10/site-packages/skbuild/cmaker.py", line 697, in make
62.48           self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)
62.48         File "/tmp/pip-build-env-z3sx64lf/overlay/lib/python3.10/site-packages/skbuild/cmaker.py", line 742, in make_impl
62.48           raise SKBuildError(msg)
62.48
62.48       An error occurred while building with CMake.
62.48         Command:
62.48           /tmp/pip-build-env-z3sx64lf/overlay/lib/python3.10/site-packages/cmake/data/bin/cmake --build . --target install --config Release --
62.48         Install target:
62.48           install
62.48         Source directory:
62.48           /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a
62.48         Working directory:
62.48           /tmp/pip-install-ikpi2bfw/opencv-python_cd41126da3fb445da2c1bce7c2f69c2a/_skbuild/linux-x86_64-3.10/cmake-build
62.48       Please check the install target is valid and see CMake's output for more information.
62.48
62.48       [end of output]
62.48
62.48   note: This error originates from a subprocess, and is likely not a problem with pip.
62.48   ERROR: Failed building wheel for opencv-python
62.48 Successfully built unstructured-inference
62.48 Failed to build opencv-python
62.48 ERROR: Could not build wheels for opencv-python, which is required to install pyproject.toml-based projects

hteeyeoh avatar Dec 11 '23 10:12 hteeyeoh

Is it something newly added in the ade source that cause something broken? tmp/pip-install-tltrnbg7/opencv-python_218517a01db34d7aa0d9c09d5f167498/_skbuild/linux-x86_64-3.10/cmake-build/3rdparty/ade/ade-0.1.1f/sources/ade/include/ade/typed_graph.hpp:22:1: note: 'std::uintptr_t' is defined in header ''; did you forget to '#include '? 412.4 21 | #include "typed_metadata.hpp" 412.4 +++ |+#include 412.4 22 |

hteeyeoh avatar Dec 12 '23 02:12 hteeyeoh

Please provide more details on GCC version. Could you try newer OpenCV releases?

asmorkalov avatar Dec 27 '23 10:12 asmorkalov

Hi @asmorkalov, I'm working with docker images where i used to install unstructured[pdf] where underlying will compile opencv-python wheel. I think with pip backtracking runtime feature (INFO: pip is looking at multiple versions of setuptools to determine which version is compatible with other requirements. This could take a while.) Hence, it will fallback to opencv-python==4.6.0.66 during the wheel compilation of image building.

Initially my Dockerfile will use python:3.10-alpine as base image. Since that period of time it start to fail with error. Hence I tried to check in docker hub and noticed that there's an update of alpine version from 3.18 to 3.19. So I tried to change my base image to use python:3.10-alpine3.18 and now it worked.

Below list down the gcc version that I captured for those docker images I mentioned above:

  • python3.10:alpine -> gcc-13.2.1_git20231014-r0 x86_64 {gcc} (GPL-2.0-or-later AND LGPL-2.1-or-later)
  • python3.10:alpine3.18 -> gcc-12.2.1_git20220924-r10 x86_64 {gcc} (GPL-2.0-or-later AND LGPL-2.1-or-later)

Some new changes required with recent gcc version upgrade i guess

hteeyeoh avatar Jan 02 '24 01:01 hteeyeoh