You are not logged in.

#1 2020-10-17 17:50:56

daniel_shub
Member
Registered: 2012-06-21
Posts: 81

[Solved] Question about opencv and Python

I maintain the psychopy package (https://aur.archlinux.org/packages/psychopy/). This package depends on the Python Opencv bindings and the package includes a Python requires.txt file that includes python-opencv. This dependency used to be satisfied by the python-opencv AUR package (https://aur.archlinux.org/cgit/aur.git/ … hon-opencv). The python-opencv AUR package was deleted because the opencv package in community (https://www.archlinux.org/packages/extra/x86_64/opencv/) includes the python bindings (I think, but I am in way over my head). The problem is that unlike the python-opencv package, the opencv package does not add any files to the Python directory (or in fact depend on Python).

My questions are.

1) Should I open a bug requesting the opencv package include the Python stuff? That does not seem right, but maybe it should be added as a split package.

2) Should the python-opencv AUR package be undeleted? That also does not seem right if it is heavily overlapping with the opencv package.

3) Should a new python-opencv AUR package be created that depends on opencv but adds the python functionality? If this is the case, anyone want to help me understand where I should look for hints to understand the opencv build process as my understanding of creating Python packages is limited to python setup.py build.

4) Am I missing a better solution?

Last edited by daniel_shub (2020-10-18 16:35:47)

Offline

#2 2020-10-17 18:03:16

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,463

Re: [Solved] Question about opencv and Python

daniel_shub wrote:

The problem is that unlike the python-opencv package, the opencv package does not add any files to the Python directory

Sure it does. usr/lib/python3.8/site-packages/cv2.cpython-38-x86_64-linux-gnu.so

Offline

#3 2020-10-17 18:27:55

daniel_shub
Member
Registered: 2012-06-21
Posts: 81

Re: [Solved] Question about opencv and Python

Scimmia wrote:
daniel_shub wrote:

The problem is that unlike the python-opencv package, the opencv package does not add any files to the Python directory

Sure it does. usr/lib/python3.8/site-packages/cv2.cpython-38-x86_64-linux-gnu.so

You are right. From Python I can run "import cv2" so the opencv package is providing some of the python functionality, but what seems to be missing is something that works with the egg-info requires.txt file of Psychopy. As I do not understand that file or Python, I am at a bit of a loss.

Offline

#4 2020-10-17 18:52:39

loqs
Member
Registered: 2014-03-06
Posts: 17,192

Re: [Solved] Question about opencv and Python

What if you patch out opencv-python from setup.cfg can psychopy use the cv2 functionality provided by opencv?

Offline

#5 2020-10-17 19:19:28

daniel_shub
Member
Registered: 2012-06-21
Posts: 81

Re: [Solved] Question about opencv and Python

loqs wrote:

What if you patch out opencv-python from setup.cfg can psychopy use the cv2 functionality provided by opencv?

Yes. If I install opencv and delete the opencv-python line from requires.txt for psychopy, everything works fine. I am not sure what you mean by "patch out opencv-python from setup.cfg". Are you suggesting just dropping the line that generates the problem line in requires.txt?

Offline

#6 2020-10-17 19:21:54

loqs
Member
Registered: 2014-03-06
Posts: 17,192

Re: [Solved] Question about opencv and Python

Yes use a patch or sed to remove that line from requirements.txt

Offline

#7 2020-10-18 09:12:53

Nocifer
Member
Registered: 2019-05-23
Posts: 13

Re: [Solved] Question about opencv and Python

Hi @daniel_shub, I'm the maintainer of an AUR package that also used to depend on python-opencv-python. For completeness's sake, here's a more detailed explanation:

The "requirements" that come with psychopy are meant to be used with pip, the python package manager, which pulls Python packages from PyPi, the online python repository (https://pypi.org/). On that repo, opencv-python is indeed a package (https://pypi.org/project/opencv-python/) which bundles the stuff required by the Python interpreter to interface with OpenCV. This is done so that when it comes to Python dependencies, Python apps can be distro- and even OS-agnostic, and run without depending on the underlying system's quirks.

For example, on Debian, OpenCV's Python bindings are split into their own package, python-opencv, which means that merely installing the main opencv package won't get you those Python bindings, and that's why psychopy needs to install them separately; but for the reason mentioned above it opts to do so from PyPi via pip (and also why opencv-python exists on PyPi in the first place).

On Arch though, which by tradition installs everything in a monolithic package and does not split upstream's files in separate subpackages like Debian does, installing OpenCV gets you everything that upstream provides, including in our case the Python bindings, so a separate package for them is not required.

The thing is, until a few months ago, presumably because (like you and me) they thought that PyPi's opencv-python was necessary for the Python bindings but missing from the Arch repos, a maintainer called @Kr1ss had taken it upon themselves to create and maintain a Debian-like python-opencv-python package on AUR. But they later found out (as @Scimmia has already pointed out) that the official OpenCV package already includes those Python bindings, which made the AUR package redundant and so @Kr1ss ended up removing it. They also made a list of all the packages that depended on it and contacted their maintainers (including me) to inform them about the issue and impending removal, but somehow they must have missed you and your package.

Long story short, since you've "converted" psychopy to resolve its dependencies from the Arch repo instead of PyPi, then, like @loqs suggested, you should simply use e.g. sed and remove the opencv-python line from setup.cfg (and also from requirements_travis.txt, and from wherever else it may be mentioned), because on Arch that dependency is already covered by the official OpenCV package.

Last edited by Nocifer (2020-10-18 09:13:45)

Offline

#8 2020-10-18 16:35:22

daniel_shub
Member
Registered: 2012-06-21
Posts: 81

Re: [Solved] Question about opencv and Python

@Nocifer thanks for the detailed response. I was contacted when the python-opencv package was being deleted. I changed the dependency at that time to opencv, rebuilt the package and ran the unit tests. Everything passed, including the tests that import cv2 and those that open the app so I told @Kr1ss we were fine with the switch. What I missed was the way the app gets opened in the unit tests is different from how the app gets opened when running it via the launcher.

Sounds like the best plan is to just patch the PsychoPy source to not "depend" on python-opencv and make the package depend on opencv.

thanks

Offline

Board footer

Powered by FluxBB