Skip to content
This repository has been archived by the owner on Sep 15, 2019. It is now read-only.

Fixed an error, Python3.7 compatibility, and opencv #35

Closed

Conversation

darosior
Copy link
Contributor

@darosior darosior commented Mar 3, 2019

This PR bumps the Cython version installed to 0.28.2 and change the assignement of the PYTHON_MINOR_VERSION var in the Makefile so that it is compatible with Python3.7, fixes a typo in the assignement of OPENCV_BUILD in the Makefile, and installs the opencv-python package (needed to use opencv) after cv2.so is built and copied in the virtualenv directory.

@@ -97,6 +97,7 @@ $(OPENCV_DEPLOY): $(OPENCV_BUILD) virtualenv
cp $(OPENCV_BUILD) $(SITE_PACKAGES_DIR)

opencv: $(OPENCV_DEPLOY)
$(PIP) install opencv-python
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should not be required since we actually compile it

Copy link
Contributor Author

@darosior darosior Mar 3, 2019

Choose a reason for hiding this comment

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

It's a wrapper not the library itself. I always installed it to use ZBarCam and thought it would be nice to install it where opencv is compiled, but I can remove it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes I would rather not use it, things seem to work smoothly without it as far as I know

@@ -25,7 +25,7 @@ OPENCV_VERSION=4.0.1
OPENCV_ARCHIVE=$(OPENCV_BASENAME).tar.gz
OPENCV_BASENAME=opencv-$(OPENCV_VERSION)
OPENCV_BUILD_LIB_DIR=$(OPENCV_BASENAME)/build/lib
OPENCV_BUILD=$(OPENCV_BUILD_LIB_DIR)/python$(PYTHON_MAJOR_VERSION)/cv2*.so
OPENCV_BUILD=$(OPENCV_BUILD_LIB_DIR)/cv2*.so
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good catch, but I think it's actually the line above that should be kept

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean that w should not use OPENCV_BUILD anymore ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No I mean you deleted the variable that we want to keep, the other should be removed and we should keep:

OPENCV_BUILD=$(OPENCV_BUILD_LIB_DIR)/python$(PYTHON_MAJOR_VERSION)/cv2*.so

Somehow at it on my compile cv2 library is dumped in: opencv-4.0.1/build/lib/python3/cv2.cpython-36m-x86_64-linux-gnu.so same thing on Travis.
For instance see this recent build log:
https://api.travis-ci.org/v3/job/501134779/log.txt

Scanning dependencies of target opencv_python3
make[3]: Leaving directory '/home/user/opencv-4.0.1/build'
make[3]: Entering directory '/home/user/opencv-4.0.1/build'
[100%] Building CXX object modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o
[100%] Linking CXX executable ../../bin/opencv_interactive-calibration
make[3]: Leaving directory '/home/user/opencv-4.0.1/build'
[100%] Built target opencv_interactive-calibration
[100%] Linking CXX shared module ../../lib/python3/cv2.cpython-36m-x86_64-linux-gnu.so
make[3]: Leaving directory '/home/user/opencv-4.0.1/build'
[100%] Built target opencv_python3
make[2]: Leaving directory '/home/user/opencv-4.0.1/build'
make[1]: Leaving directory '/home/user/opencv-4.0.1/build'
cp opencv-4.0.1/build/lib/python3/cv2*.so venv/lib/python3.6/site-packages

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, for some reason it doesn't output to the same path for me.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ouch OK that's annoying. For me as as well when it was on opencv2 it was in build/lib/cv2*.so.
Maybe we should try a hybrid approach with a comment explaining both path are somewhat possible. But I would keep that for later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, found out that actuallly that there is build/lib/cv2.so and I thought this one was the lib we wanted to copy.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh yes I remember I had the same issue when migrating to opencv4, so yes I also have that lib, but it's not the one being used at the end somehow. I didn't investigate why.
But good to know that you also have something in opencv-4.0.1/build/lib/python3/ that way we can keep the Makefile "simple"

@AndreMiras
Copy link
Collaborator

Thanks I get the idea, two of the tests are failing with:

Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package libpython3.-dev
E: Couldn't find any package by glob 'libpython3.-dev'
E: Couldn't find any package by regex 'libpython3.-dev'
Makefile:49: recipe for target 'system_dependencies' failed
make: *** [system_dependencies] Error 100
The command '/bin/sh -c make' returned a non-zero code: 2
The command "docker build --tag=$TAG --file=$DOCKERFILE --build-arg CI ." failed and exited with 2 during .
Your build has been stopped.

See https://travis-ci.org/kivy-garden/garden.zbarcam/builds/501117072 for details.
Having Python3.7 support makes total sense, but I'd like to have it with regression tests also. So I'll probably add it to Docker system dependencies and tox testing. I'm bit scared about tox because it might double the testing time. But well I'll give it a try.
Thanks for the heads up!

@AndreMiras
Copy link
Collaborator

I've bumped Cython as you suggested and added python3.7 to both tox and Docker and tests are running smoothly. However now the CI may run for too long a be interrupted by Travis. I'll try pushing the branch nonetheless, but we should probably find a way around to it

AndreMiras added a commit that referenced this pull request Mar 3, 2019
AndreMiras added a commit that referenced this pull request Mar 3, 2019
@darosior
Copy link
Contributor Author

darosior commented Mar 3, 2019

I'll remove the opencv-python and BUILD_OPENCV modifications from this branch

@darosior darosior closed this Mar 3, 2019
@@ -15,7 +15,7 @@ SYSTEM_DEPENDENCIES= \
wget
OS=$(shell lsb_release -si)
PYTHON_MAJOR_VERSION=3
PYTHON_MINOR_VERSION=6
PYTHON_MINOR_VERSION=$(shell python -c 'import sys;print(sys.version_info[1])')
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see the idea, and indeed we could probably improve that Makefile somehow, but this is currently hardcoded somehow on purpose.
Because for instance on Ubuntu 18.04 LTS default system Python is 2.7 (shame!). The purpose of this Makefile is to prepare the virtualenv. Do you see what I mean?
However I understand the need of wanting it to automatically prepare a Python3.7 environment for you without having to edit the Makefile. In this case you can use the built-in variable overriding mechanism of Makefile, e.g. via:

make PYTHON_MINOR_VERSION=7

That will do just what you need.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants