-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Move python bindings into separate cmake target #6220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move python bindings into separate cmake target #6220
Conversation
|
lgtm, but @ev-mp would know more about the packaging side of our CMake infrastructure |
|
Any progress here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@morxa hellom
I'm testing this PR on top of the latest v2.35.0 with Ubuntu18 LTS and get the following interrupt:
git/librealsense/build$ sudo make uninstall && make clean && cmake -DBUILD_EXAMPLES=true -DCMAKE_BULID_TYPE=Debug -DBUILD_PYTHON_BINDINGS=true && make -j$(($(nproc)-1))
[sudo] password for user:
-- Internet connection identified
-- Info: REALSENSE_VERSION_STRING=2.35.0
-- Setting Unix configurations
-- using RS2_USE_V4L2_BACKEND
CMake Error at wrappers/python/CMakeLists.txt:10 (find_package):
By not providing "FindPython.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Python", but
CMake did not find one.
Could not find a package configuration file provided by "Python" with any
of the following names:
PythonConfig.cmake
python-config.cmake
Add the installation prefix of "Python" to CMAKE_PREFIX_PATH or set
"Python_DIR" to a directory containing one of the above files. If "Python"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "/home/user/git/librealsense/build/CMakeFiles/CMakeOutput.log".
Makefile:3874: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1Python 2.7 and 3.7 are installed (including -dev)
Please advise
|
Right, I just realized the new cmake Python module requires cmake 3.12. Ubuntu 18.04 ships with cmake 3.10. I guess you still want to support older cmake versions? |
|
We do keep support for older cmake version (Ubuntu 14). BTW, the error I got was on Ubuntu 18 with cmake 3.10.2 |
|
OK, I'll try to update the PR to also work with older cmake versions. |
|
@ev-mp can you please check my new changes? Thanks! |
wrappers/python/CMakeLists.txt
Outdated
| message(WARNING "Python Bindings being built despite unset option because they are required for python documentation") | ||
| endif() | ||
|
|
||
| if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@morxa , I moved the testing to the Debian builds but still - the follow statement is not compatible with Cmake v3.5 on Ubuntu 16 and produces the following error
16:49:53 CMake Error at wrappers/python/CMakeLists.txt:10 (if):
16:49:53 if given arguments:
16:49:53
16:49:53 "CMAKE_VERSION" "VERSION_GREATER_EQUAL" "3.12"
16:49:53
16:49:53 Unknown arguments specified
16:49:53
16:49:53
16:49:53 -- Configuring incomplete, errors occurred!Invoked with the following configuration (python 3.5)
16:49:52 cmake config:../../ -G "Unix Makefiles" -DPYTHON_EXECUTABLE=/usr/bin/python3.5 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_EXAMPLES=true -DBUILD_SHARED_LIBS=false -DBUILD_WITH_OPENMP=false -DENFORCE_METADATA=true -DBUILD_CSHARP_BINDINGS=false -DBUILD_PYTHON_BINDINGS=true -DBUILD_PYTHON_DOCS=false -DBUILD_WITH_TM2=true -DCMAKE_INSTALL_PREFIX=../../realsense2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Older cmake does not know VERSION_GREATER_EQUAL, only VERSION_GREATER. :/
I inversed the logic, can you check again? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try it again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@morxa ,please rebase it with v2.35.2 or later - the gaps are too big to bridge...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
43f1c5e to
7e786da
Compare
|
@morxa hello, the PR now verified on Debians and now I'm also testing it with Pypi. |
Python looks for the bindings in its SITEARCH directory, not in LIBDIR. Use Python_SITEARCH/pyrealsense2 as default but allow overriding the install dir by setting PYTHON_INSTALL_DIR.
Having the python bindings in their own target removes the dependency on the bindings if the consumer library does not use the python bindings.
This allows using `find_package(pyrealsense2)` in consumers of the python bindings.
With cmake < 3.12, the FindPython module does not exist yet. Use FindPythonInterp and FindPythonLibs instead.
7e786da to
3a4d1e6
Compare
|
I rebased on I'm not sure I understand the problem with the examples, what do you mean by debian target? I don't see a debian make target. Also, which examples do you mean? The python examples? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was referring to realsense SDK targets - when invoking make pyrealsense2 I got realsense-viewer built as well. Now when I build it is not reproduced so I think it was indeed a cmake cache glitch.
Anyhow, it's good to go now.
Thanks again for your contribution.
|
Great :) Thanks for the review! |
/usr/lib64(or/usr/local/lib64).Resolves #6124.