Skip to content

Conversation

@janbox70
Copy link

@janbox70 janbox70 commented Mar 25, 2025

upgrade opencv-python package to 4.11.0.86.

@mhsmith
Copy link
Member

mhsmith commented Mar 26, 2025

Thanks, I'll look at this as soon as I can.

Meanwhile, can you confirm you've tested this as described in the "Testing a package" section in the README? Once you've done that, please let me know which Python versions and ABIs you've tested. You don't need to do them all, but you should do at least one.


# try to use dynamic symbols linking with libpython.so
set(OPENCV_FORCE_PYTHON_LIBS OFF CACHE BOOL "")
+ string(REPLACE "-Wl,--no-undefined-version" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}") # Chaquopy: fixbug for '-version' while compiling
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the "Chaquopy" comment onto its own line above the change, and edit it to explain exactly why the change is necessary, including any error messages.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll update when test is passed.

@janbox70
Copy link
Author

janbox70 commented Apr 4, 2025

Thanks, I'll look at this as soon as I can.

Meanwhile, can you confirm you've tested this as described in the "Testing a package" section in the README? Once you've done that, please let me know which Python versions and ABIs you've tested. You don't need to do them all, but you should do at least one.

I'm doing test with android studio as described in README. The python version is 3.10 and ABI is x86_64.
I got following error in python console in the pkgtest app:

Python 3.10.15 (main, Oct 12 2024, 20:50:26) [Clang 18.0.2 (https://android.googlesource.com/toolchain/llvm-project d8003a456 on linux
The current application context is available in the variable 'context'.
>>> import cv2
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "import.pxi", line 60, in java.chaquopy.import_override
  File "/data/data/com.chaquo.python.pkgtest3/files/chaquopy/AssetFinder/requirements/cv2/__init__.py", line 181, in <module>
  File "/data/data/com.chaquo.python.pkgtest3/files/chaquopy/AssetFinder/requirements/cv2/__init__.py", line 111, in bootstrap
  File "/data/data/com.chaquo.python.pkgtest3/files/chaquopy/AssetFinder/requirements/cv2/__init__.py", line 109, in load_first_config
ImportError: OpenCV loader: missing configuration file: ['config.py']. Check OpenCV installation.

I've checked the build history, and found that config.py was built and packed into the wheel.

creating _skbuild/linux-x86_64-3.10/setuptools/bdist.linux-x86_64/wheel/opencv_python-4.11.0.86.dist-info/WHEEL
creating 'server/pypi/packages/opencv-python/build/4.11.0.86/cp310-cp310-android_24_x86_64/src/dist/tmprl0ag0bn/opencv_python-4.11.0.86-cp310-cp310-linux_x86_64.whl' and adding '_skbuild/linux-x86_64-3.10/setuptools/bdist.linux-x86_64/wheel' to it
adding 'cv2/LICENSE-3RD-PARTY.txt'
adding 'cv2/LICENSE.txt'
adding 'cv2/__init__.py'
adding 'cv2/__init__.pyi'
adding 'cv2/config-3.py'
adding 'cv2/config.py'
adding 'cv2/cv2.abi3.so'
adding 'cv2/load_config_py2.py'
adding 'cv2/load_config_py3.py'
adding 'cv2/py.typed'
adding 'cv2/version.py'
...

Then I checked files in pkgtest/app/build/python/pip/debug/common/cv2 in the pkgtest app in android studio, and found following .py files except config.py.

__init__.py
config-3.py
load_config_py2.py
load_config_py3.py
version.py
...

And I found config.py in pkgtest/app/build/python/pip/debug/x86_64/cv2.

Can you please identify this issue?

@mhsmith
Copy link
Member

mhsmith commented Apr 16, 2025

If the file is in debug/x86_64 but not in debug/common, then you must be installing multiple ABIs, and the file is different between them. This is not in itself a problem, as the directories will be merged back together at runtime by the importer. But you can simplify the situation by temporarily editing the abiFilters of the pkgtest app to the one ABI you're testing.

It looks like the actual problem is that OpenCV expects config.py to exist as an individual file at runtime. As described here, for performance reasons Chaquopy doesn't do this with Python modules by default. You may need to add cv2 to the extractPackages list in the pkgtest build.gradle file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Update opencv version

2 participants