Building integration but struggling to get opencv installed in HA

First time trying to build an HA integration, so apologies if this question is fairly dumb.

I’ve got a small app I’ve built that uses opencv and have it running in docker on my server. Had it using MQTT to feed sensor data into HA and everything is working fine there.

As part of a learning exercise, I wanted to turn this whole thing into an HA integration and I for the life of me can’t get it to work.

Found a somewhat relevant post here: Opencv integration library fails to load after python 3.10 update · Issue #74566 · home-assistant/core · GitHub but adding numpy and specifying the version didn’t make a difference.

In my manifest.json I have:

"requirements": ["numpy", "opencv-python-headless", "pytesseract"],

In my requirements.txt I have:

opencv-python-headless==4.8.1.78
numpy>=1.21.0,<2.0.0
pytesseract>=0.3.8

I’ve tried not specifying versions, as the later builds do add Python 3.13 support. I’ve tried pinning to older versions. All the results are the same.

When trying to setup the integration, I get this error in the logs:

Unable to install package opencv-python-headless: × Failed to build opencv-python-headless==4.11.0.86 ├─▶ The build backend returned an error ╰─▶ Call to backend.build_wheel failed (exit status: 1) [stderr] Traceback (most recent call last): File “/tmp/.tmpU6dtG3/builds-v0/.tmpLrTskM/lib/python3.13/site-packages/skbuild/command/bdist_wheel.py”, line 13, in from setuptools.command.bdist_wheel import WheelFile # type: ignore[attr-defined] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ModuleNotFoundError: No module named ‘setuptools.command.bdist_wheel’ During handling of the above exception, another exception occurred: Traceback (most recent call last): File “/tmp/.tmpU6dtG3/builds-v0/.tmpLrTskM/lib/python3.13/site-packages/wheel/bdist_wheel.py”, line 11, in from setuptools.command.bdist_wheel import bdist_wheel as bdist_wheel ModuleNotFoundError: No module named ‘setuptools.command.bdist_wheel’ The above exception was the direct cause of the following exception: Traceback (most recent call last): File “”, line 14, in requires = get_requires_for_build({}) File “/tmp/.tmpU6dtG3/sdists-v9/pypi/opencv-python-headless/4.11.0.86/CmzB16cjOruWDnHW2QvDg/src/_build_backend/backend.py”, line 10, in get_requires_for_build_wheel from skbuild.exceptions import SKBuildError File “/tmp/.tmpU6dtG3/builds-v0/.tmpLrTskM/lib/python3.13/site-packages/skbuild/init.py”, line 10, in from .setuptools_wrap import setup File “/tmp/.tmpU6dtG3/builds-v0/.tmpLrTskM/lib/python3.13/site-packages/skbuild/setuptools_wrap.py”, line 30, in from .command import ( …<12 lines>… ) File “/tmp/.tmpU6dtG3/builds-v0/.tmpLrTskM/lib/python3.13/site-packages/skbuild/command/bdist_wheel.py”, line 16, in from wheel.bdist_wheel import bdist_wheel as _bdist_wheel File “/tmp/.tmpU6dtG3/builds-v0/.tmpLrTskM/lib/python3.13/site-packages/wheel/bdist_wheel.py”, line 13, in raise ImportError(ERROR) from exc ImportError: The ‘wheel.bdist_wheel’ module has been removed. Please update your setuptools to v70.1 or later. If you’re explicitly importing ‘wheel.bdist_wheel’, please update your import to point to ‘setuptools.command.bdist_wheel’ instead. hint: This usually indicates a problem with the package or the build environment.

I’ve tried adding setuptools to the manifest/requirements, but it makes no difference.

So I tried exploring a different route of bundling it into my integration directly, but am not 100% sure exactly how that’s done. Piecing a few different posts together, I believe I can do something similar to this:

custom_components/
└── your_integration/
    ├── __init__.py
    ├── manifest.json
    ├── config_flow.py
    └── lib/
        └── small_library/
            ├── __init__.py
            └── module.py

Then import with:

from .lib.small_library import module

However, this obviously is a bit more complicated for OpenCV, as it’s not just a single file.

Curious from folks who are more experienced here as to how I should proceed? I was really hoping to go the manifest.json route so it’s handled automatically as part of the integration install as opposed to bundling it manually.

Doing more research (https://www.perplexity.ai/search/how-do-i-manually-bundle-openc-2l6wbba4T7SygBVVSgu.Ag) , it seems like building my own custom wheel to include might be the best option due to the limited build environment directly in HA?