Skip to content
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

Python bindings don't respect CMAKE_INSTALL_PREFIX #10820

Closed
m-elwin opened this issue Aug 24, 2022 · 4 comments
Closed

Python bindings don't respect CMAKE_INSTALL_PREFIX #10820

m-elwin opened this issue Aug 24, 2022 · 4 comments

Comments

@m-elwin
Copy link

m-elwin commented Aug 24, 2022

  • Before opening a new issue, we wanted to provide you with some useful suggestions (Click "Preview" above for a better view):

  • All users are welcomed to report bugs, ask questions, suggest or request enhancements and generally feel free to open new issue, even if they haven't followed any of the suggestions above :)


Required Info
Camera Model Any
Firmware Version N/A}
Operating System & Version {Linux}
Kernel Version (Linux Only) (e.g. 4.14.13)
Platform PC
SDK Version { 2.50.0 }
Language {python }
Segment {Robot/Smartphone/VR/AR/others }

Issue Description

When configuring a build with -DBUILD_PYTHON_BINDINGS=ON, the generated
python libraries are always installed relative to / (e.g., /usr/lib/python3.10/dist-packages), regardless of the value of CMAKE_INSTALL_PREFIX.

Specifying -DPYTHON_INSTALL_DIR manually works around this issue.

I believe the issue is related to how the Python install directory is determined.
In wrappers/python/CMakeLists.txt:64, PYTHON_INSTALL_DIR is set to ${Python_SITEARCH}, which I believe is always an absolute path.

I think the code used for CMake Version <3.12 may not have this issue.

@MartyG-RealSense
Copy link
Collaborator

Thanks very much @m-elwin for highlighting this CMake issue to the RealSense community and advising about a manual workaround!

m-elwin added a commit to m-elwin/librealsense that referenced this issue Aug 25, 2022
…INSTALL_PREFIX

${Python_SITEARCH} seems to return an absolute path so it can't
be used to find the install location of python libraries.

Instead the directory is now specified in a manner similar to that
used for cmake versions < 3.12 (which use an older cmake module to
find Python)
@MartyG-RealSense
Copy link
Collaborator

Case closed due to no further comments received. Thanks again @m-elwin for sharing your workaround!

@maloel
Copy link
Collaborator

maloel commented Sep 21, 2022

@m-elwin
First, thanks for your contribution.
But I have to ask, why do you want to override the install directory?
Installation is supposed to put the compiled code in a place where a python import command would see it. Python itself sets this folder and, according to the docs, that's the folder that should be used.

Do you have two different Python installations? Is CMake finding the wrong Python executable?

@m-elwin
Copy link
Author

m-elwin commented Sep 27, 2022

Wanted to install under my home directory instead of system python directory (which requires root).

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

No branches or pull requests

3 participants