package py3-opencv has incorrect dependency on python 4.10.0
Dockerfile
FROM alpine:3.21.2
RUN apk add py3-pip
RUN apk add py3-opencv
RUN pip install --break-system-packages --no-cache-dir --upgrade unoconv
Output
2.024 File "/usr/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 96, in _inner_run
2.024 return self.run(options, args)
2.024 ^^^^^^^^^^^^^^^^^^^^^^^
2.024 File "/usr/lib/python3.12/site-packages/pip/_internal/cli/req_command.py", line 67, in wrapper
2.024 return func(self, options, args)
2.024 ^^^^^^^^^^^^^^^^^^^^^^^^^
2.024 File "/usr/lib/python3.12/site-packages/pip/_internal/commands/install.py", line 483, in run
2.024 installed_versions[distribution.canonical_name] = distribution.version
2.024 ^^^^^^^^^^^^^^^^^^^^
2.024 File "/usr/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_dists.py", line 167, in version
2.024 return parse_version(version)
2.024 ^^^^^^^^^^^^^^^^^^^^^^
2.024 File "/usr/lib/python3.12/site-packages/pip/_vendor/packaging/version.py", line 56, in parse
2.024 return Version(version)
2.024 ^^^^^^^^^^^^^^^^
2.024 File "/usr/lib/python3.12/site-packages/pip/_vendor/packaging/version.py", line 202, in __init__
2.024 raise InvalidVersion(f"Invalid version: '{version}'")
2.024 pip._vendor.packaging.version.InvalidVersion: Invalid version: 'python-4.10.0'
------
Dockerfile.test:6
--------------------
4 | RUN apk add py3-pip
5 | RUN apk add py3-opencv
6 | >>> RUN pip install --break-system-packages --no-cache-dir --upgrade unoconv
Installing pip packages to the system is unsupported (as one could guess due to --break-system-packages). You can instead try it in a virtualenv or try installing the system package.
The system package is currently in the testing repository. Therefore you should use the alpine:edge image and use apk add -X https://dl-cdn.alpinelinux.org/alpine/edge/testing py3-unoconv
@fossdd
I believe the problem is not with unoconv, but with the system package py3-opencv.
I'm facing the same issue.
What seems to happen is after installing py3-opencv, the next pip install of whatever package will fail with the following error message:
WARNING: Error parsing dependencies of opencv: Invalid version: 'python-4.10.0'
...
pip._vendor.packaging.version.InvalidVersion: Invalid version: 'python-4.10.0'
The version in the error message 'python-4.10.0' is exactly the same as the version of the previously installed py3-opencv.
I experienced the issue on alpine:3.20.3, but confirmed it also happens on the latest alpine:3.21.3.
Could someone please check if there is some configuration miss around py3-opencv?
Thanks,
So far it only happens on the GitHub hosted runners ubuntu-latest for me.
The builds on my macOS local machine are all fine.
fyi: The same build on alpine:3.20.3 was fine at 2024/11/11. There could be some change on the GitHub runner that is related.
I see. There is some trickery happening in py3-opencv: https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/community/opencv/APKBUILD#L169-182
Can you reproduce it in alpine:edge?
I can't reproduce it in alpine:edge or alpine:3.21.2:
➜ ~ podman run --rm -it alpine:3.21.2
Resolved "alpine" as an alias (/etc/containers/registries.conf.d/00-shortnames.conf)
Trying to pull docker.io/library/alpine:3.21.2...
Getting image source signatures
Copying blob 1f3e46996e29 done |
Copying config b0c9d60fc5 done |
Writing manifest to image destination
/ # apk add py3-pip py3-opencv
fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.21/community/x86_64/APKINDEX.tar.gz
...
OK: 683 MiB in 244 packages
/ # pip install --break-system-packages --no-cache-dir --upgrade unoconv
Collecting unoconv
Downloading unoconv-0.9.0-py2.py3-none-any.whl.metadata (12 kB)
Downloading unoconv-0.9.0-py2.py3-none-any.whl (29 kB)
Installing collected packages: unoconv
Successfully installed unoconv-0.9.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
/ #
Happens on both alpine:edge and alpine:3.21.2 for me.
On alpine:edge:
WARNING: Error parsing dependencies of opencv: Invalid version: 'python-4.11.0'
...
pip._vendor.packaging.version.InvalidVersion: Invalid version: 'python-4.11.0'
On alpine:3.21.2:
WARNING: Error parsing dependencies of opencv: Invalid version: 'python-4.10.0'
...
pip._vendor.packaging.version.InvalidVersion: Invalid version: 'python-4.10.0'
It might be that it only happens on the GitHub runners ubuntu-latest for some reason.
cp -r opencv-*.dist-info opencv-python-$pkgver.dist-info
Looks like it has treated the whole python-$pkgver part as a version tag.
https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/community/opencv/APKBUILD#L180-182 Maybe because this sed command was not working.
Looking manually at the file in a installation it seems to work:
~ $ cat /usr/lib/python3.12/site-packages/opencv-python-4.11.0.dist-info/METADATA
Metadata-Version: 2.1
Name: opencv-python
Version: 4.11.0
tbh i've no idea what went wrong and why it doesn't work for you but for me
I created a simple demo here: https://github.com/unext-wendong/alpine-opencv-demo/blob/main/Dockerfile
Here is the build: https://github.com/unext-wendong/alpine-opencv-demo/actions/runs/13812958242/job/38638704728
@fossdd I got some new findings today.
To verify if the issue is related to the ubuntu version of the GitHub runner, I did a comparison test where I have two GitHub workflows with the same settings except the runner label. https://github.com/unext-wendong/alpine-opencv-demo/blob/main/.github/workflows/build-on-ubuntu2404.yaml https://github.com/unext-wendong/alpine-opencv-demo/blob/main/.github/workflows/build-on-ubuntu2204.yaml
The result is while the one that runs on ubuntu-24.04 failed, the one on ubuntu-22.04 succeeded: https://github.com/unext-wendong/alpine-opencv-demo/actions/runs/13832191118 (failed on ubuntu-24.04) https://github.com/unext-wendong/alpine-opencv-demo/actions/runs/13832192182 (succeeded on ubuntu-22.04)
So we can now say that there are some changes in runner environment that caused the trick in py3-opencv to fail.
This is really strange as the failure happens inside a docker build which should be isolated to some extend from the host environment.
@fossdd Is there any plan to have an investigation on this issue?
Before the ubuntu-22.04 runners are retried, this issue can still be worked around, but it will become a real problem after that.
Please reach out to GitHub for support since this is clearly not reproducible without a GitHub environment.
@fossdd
Well this issue does appear to be platform specific and reproduces on GitHub's ubuntu-22.04 runners, but I wouldn't say it's GitHub exclusive.
For example, clearly this is not on GitHub runner: https://github.com/Minims/SomfyProtect2MQTT/issues/188#issuecomment-2646165091
And reading the author (of this issue) 's original issue report, it also doesn't feel like it's from GitHub runner: https://github.com/Stirling-Tools/Stirling-PDF/issues/2934#issue-2846070526
Hope this is convincing enough to you.
I would suggest someone familiar with that py3-opencv hack to look into it.
Hi all, We have worked round the issue by using venv. It's not ideal as we would prefer to use apk wherever we can.
What we can say is that it is failing on local machines as well as on our GitHub Runner if that's helpful.
Thanks for looking into it 😄