Skip to content

Commit 370cd09

Browse files
committed
[cppyy] Move libcppyy.so to <LIBDIR>/cppyy/libcppyy.so
When compiling ROOT in Gentoo, the following warning is issued: * Verifying compiled files for python3.13 * * QA Notice: The following unexpected files/directories were found * top-level in the site-packages directory: * * /usr/lib/python3.13/site-packages/libcppyy.so.6.37.01 * * This is most likely a bug in the build system. More information * can be found in the Python Guide: * https://projects.gentoo.org/python/guide/qawarn.html#stray-top-level-files-in-site-packages Similarly to #14917, this can be solved by moving it to <LIBDIR>/cppyy. Therefore: - Move the libray. - Update its RUNPATH for it to find ROOT libraries. - Help Windows find it at its new location. Fix #20015.
1 parent e5fd81f commit 370cd09

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

bindings/pyroot/cppyy/CPyCppyy/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ endif()
7373
add_library(cppyy SHARED src/CPyCppyyPyModule.cxx)
7474

7575
# Set the suffix to '.so' and the prefix to 'lib'
76-
set_target_properties(cppyy PROPERTIES ${ROOT_LIBRARY_PROPERTIES})
76+
set_target_properties(cppyy PROPERTIES ${ROOT_LIBRARY_PROPERTIES}
77+
LIBRARY_OUTPUT_DIRECTORY ${localruntimedir}/cppyy)
7778
if(MSVC)
7879
target_link_libraries(cppyy PRIVATE CPyCppyy)
7980
set_target_properties(cppyy PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
@@ -116,7 +117,7 @@ set_property(GLOBAL APPEND PROPERTY ROOT_EXPORTED_TARGETS cppyy)
116117

117118
if(NOT MSVC)
118119
# Make sure that relative RUNPATH to main ROOT libraries is always correct.
119-
ROOT_APPEND_LIBDIR_TO_INSTALL_RPATH(cppyy ${CMAKE_INSTALL_PYTHONDIR})
120+
ROOT_APPEND_LIBDIR_TO_INSTALL_RPATH(cppyy ${CMAKE_INSTALL_PYTHONDIR}/cppyy)
120121
ROOT_APPEND_LIBDIR_TO_INSTALL_RPATH(CPyCppyy ${CMAKE_INSTALL_LIBDIR})
121122
endif()
122123

@@ -127,9 +128,9 @@ install(TARGETS CPyCppyy EXPORT ${CMAKE_PROJECT_NAME}Exports
127128
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries)
128129

129130
install(TARGETS cppyy EXPORT ${CMAKE_PROJECT_NAME}Exports
130-
RUNTIME DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries
131-
LIBRARY DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries
132-
ARCHIVE DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries)
131+
RUNTIME DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/cppyy COMPONENT libraries
132+
LIBRARY DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/cppyy COMPONENT libraries
133+
ARCHIVE DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/cppyy COMPONENT libraries)
133134

134135
file(COPY ${headers} DESTINATION ${CMAKE_BINARY_DIR}/include/CPyCppyy)
135136

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@
6666
from . import _typemap
6767
from ._version import __version__
6868

69+
# Help Windows locate cppyy/libcppyy.so, which should be in the same location as the current file:
70+
if "win32" in sys.platform:
71+
os.add_dll_directory(os.path.dirname(__file__))
72+
6973
# import separately instead of in the above try/except block for easier to
7074
# understand tracebacks
7175
if ispypy:
@@ -339,7 +343,9 @@ def add_library_path(path):
339343

340344
apipath_extra = os.path.join(os.path.dirname(apipath), 'site', 'python'+ldversion)
341345
if not os.path.exists(os.path.join(apipath_extra, 'CPyCppyy')):
342-
import glob, libcppyy
346+
import glob
347+
348+
import cppyy.libcppyy as libcppyy
343349
ape = os.path.dirname(libcppyy.__file__)
344350
# a "normal" structure finds the include directory up to 3 levels up,
345351
# ie. dropping lib/pythonx.y[md]/site-packages

bindings/pyroot/cppyy/cppyy/python/cppyy/_cpython_cppyy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
except ImportError:
2828
c = None
2929

30-
import libcppyy as _backend
30+
import cppyy.libcppyy as _backend
3131

3232
if c is not None:
3333
_backend._cpp_backend = c

0 commit comments

Comments
 (0)