Skip to content

CMAKE_INSTALL_PYTHONDIR on macOS creates broken symlinks #8933

@chrisburr

Description

@chrisburr
  • Checked for duplicates

Describe the bug

As of 6.24.04, building with CMAKE_INSTALL_PYTHONDIR on macOS causes pyroot to not be functional as the installed symlink is:

lib/python3.9/site-packages/libcppyy_backend3_9.dylib@ -> ../..//libcppyy_backend3_9.dylib

whereas the actually Python module is in:

lib/libcppyy3_9.6.24.04.so

which causes import ROOT to fail:

Traceback (most recent call last):
  File "/Users/christopherburr/miniconda3/conda-bld/root_base_1630311151559/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place/lib/python3.9/site-packages/cppyy/__init__.py", line 60, in <module>
    importlib.import_module(libcppyy_mod_name)
  File "/Users/christopherburr/miniconda3/conda-bld/root_base_1630311151559/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'libcppyy3_9'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/christopherburr/miniconda3/conda-bld/root_base_1630311151559/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place/lib/python3.9/site-packages/ROOT/__init__.py", line 22, in <module>
    import cppyy
  File "/Users/christopherburr/miniconda3/conda-bld/root_base_1630311151559/_test_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_place/lib/python3.9/site-packages/cppyy/__init__.py", line 62, in <module>
    raise ImportError(
ImportError: Failed to import libcppyy3_9. Please check that ROOT has been built for Python 3.9
Tests failed for root_base-6.24.4-py39h04197d9_0.tar.bz2 - moving package to /Users/christopherburr/miniconda3/conda-bld/broken

This issue was introduced in aefe374 as the patch uses CMAKE_SHARED_LIBRARY_SUFFIX despite the fact that the suffix is overridden by:

# Set the suffix to '.so' and the prefix to 'lib'
set_target_properties(${libname} PROPERTIES ${ROOT_LIBRARY_PROPERTIES})

if(soversion)
set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES}
VERSION ${ROOT_VERSION}
SOVERSION ${ROOT_MAJOR_VERSION}.${ROOT_MINOR_VERSION}
SUFFIX ${libsuffix}
PREFIX ${libprefix} )
else()
set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES}
SUFFIX ${libsuffix}
PREFIX ${libprefix}
IMPORT_PREFIX ${libprefix} )
endif()

if(CMAKE_PROJECT_NAME STREQUAL ROOT)
set(libsuffix .so)
else()
set(libsuffix ${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()

Expected behavior

CMAKE_INSTALL_PYTHONDIR creates the correctly named symlinks for the binaries it installed.

To Reproduce

Setup

Additional context

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions