Skip to content

CMake: use of Python_SITELIB #23

@nim65s

Description

@nim65s

Hi,

LIBRARY DESTINATION ${Python_SITELIB}

CMake FindPython seems to populate Python_SITELIB to an absolute system path.

ROS builds are thus failing with eg. https://build.ros2.org/job/Kdev__nanoeigenpy__ubuntu_noble_amd64/4/console:

PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.12/dist-packages/nanoeigenpy.pyi'
CMake Error at cmake_install.cmake:89 (file):
  file INSTALL cannot copy file
  "/tmp/ws/build_isolated/nanoeigenpy/lib/nanoeigenpy.cpython-312-x86_64-linux-gnu.so"
  to
  "/usr/local/lib/python3.12/dist-packages/nanoeigenpy.cpython-312-x86_64-linux-gnu.so":
  Permission denied.

Same issue on Nix side, where this is patched: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/python-modules/nanoeigenpy/default.nix#L38

PermissionError: [Errno 13] Permission denied:
'/nix/store/…-python3-3.12.9/lib/python3.12/site-packages/nanoeigenpy.pyi'

That CMake variable is initialized from sysconfig.get_path('purelib'), but in other projects we instead use Path(sysconfig.get_path('purelib')).relative_to(sysconfig.get_path('data')) to fix this issue, ref. https://github.com/jrl-umi3218/jrl-cmakemodules/blob/c815b3ba45fa8b7cf4b7a21b69b26ad0bc04fd5c/python.cmake#L310C62-L310C137

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions