Skip to content

Commit dc560e3

Browse files
committed
[PyROOT] Move CPython extensions into subdirectories
Closes #14917.
1 parent 4550b57 commit dc560e3

File tree

12 files changed

+38
-21
lines changed

12 files changed

+38
-21
lines changed

bindings/jupyroot/CMakeLists.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ set(libname JupyROOT)
3434

3535
# libJupyROOT uses ROOT headers from source dirs and depends on Core
3636
add_library(${libname} SHARED src/IOHandler.cxx)
37+
38+
# To make sure that the library also ends up in the right subdirectory in the
39+
# build directory tree.
40+
if(MSVC)
41+
set_target_properties(${libname} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/JupyROOT)
42+
else()
43+
set_target_properties(${libname} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/JupyROOT)
44+
endif()
45+
3746
# Set the suffix to '.so' and the prefix to 'lib'
3847
set_target_properties(${libname} PROPERTIES ${ROOT_LIBRARY_PROPERTIES})
3948
if(MSVC)
@@ -56,9 +65,9 @@ endforeach()
5665

5766
# Install library
5867
install(TARGETS ${libname} EXPORT ${CMAKE_PROJECT_NAME}Exports
59-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
60-
LIBRARY DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries
61-
ARCHIVE DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries)
68+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/JupyROOT COMPONENT libraries
69+
LIBRARY DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/JupyROOT COMPONENT libraries
70+
ARCHIVE DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/JupyROOT COMPONENT libraries)
6271

6372
# Install Python sources and bytecode
6473
install(DIRECTORY ${localruntimedir}/JupyROOT

bindings/jupyroot/python/JupyROOT/helpers/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import queue
2020

2121
from JupyROOT import helpers
22-
import libJupyROOT as _lib
22+
import JupyROOT.libJupyROOT as _lib
2323

2424

2525
class IOHandler(object):

bindings/pyroot/pythonizations/CMakeLists.txt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ set(libname ROOTPythonizations)
144144

145145
add_library(${libname} SHARED ${cpp_sources})
146146

147+
# To make sure that the library also ends up in the right subdirectory in the
148+
# build directory tree.
149+
if(MSVC)
150+
set_target_properties(${libname} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/ROOT)
151+
else()
152+
set_target_properties(${libname} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/ROOT)
153+
endif()
154+
147155
# Insert the ROOTPythonizationsPySources in the dependency graph
148156
add_dependencies(${libname} ROOTPythonizationsPySources)
149157

@@ -187,16 +195,16 @@ target_link_libraries(PyROOT INTERFACE cppyy_backend cppyy ROOTPythonizations)
187195

188196
# Install library
189197
install(TARGETS ${libname} EXPORT ${CMAKE_PROJECT_NAME}Exports
190-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
191-
LIBRARY DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries
192-
ARCHIVE DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries)
198+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/ROOT COMPONENT libraries
199+
LIBRARY DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/ROOT COMPONENT libraries
200+
ARCHIVE DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/ROOT COMPONENT libraries)
193201

194202
# Install meta-target PyROOT3 (INTERFACE library)
195203
# Install library
196204
install(TARGETS PyROOT EXPORT ${CMAKE_PROJECT_NAME}Exports
197-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
198-
LIBRARY DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries
199-
ARCHIVE DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries)
205+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/ROOT COMPONENT libraries
206+
LIBRARY DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/ROOT COMPONENT libraries
207+
ARCHIVE DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/ROOT COMPONENT libraries)
200208

201209
# Install Python sources and bytecode
202210
install(DIRECTORY ${localruntimedir}/ROOT

bindings/pyroot/pythonizations/python/ROOT/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
import cppyy
2626
import sys, importlib
27-
import libROOTPythonizations
27+
import ROOT.libROOTPythonizations
2828

2929
# Build cache of commonly used python strings (the cache is python intern, so
3030
# all strings are shared python-wide, not just in PyROOT).
@@ -184,8 +184,8 @@ def cleanup():
184184
facade.__dict__["app"].keep_polling = False
185185
facade.__dict__["app"].process_root_events.join()
186186

187-
if "libROOTPythonizations" in sys.modules:
188-
backend = sys.modules["libROOTPythonizations"]
187+
if "ROOT.libROOTPythonizations" in sys.modules:
188+
backend = sys.modules["ROOT.libROOTPythonizations"]
189189

190190
# Make sure all the objects regulated by PyROOT are deleted and their
191191
# Python proxies are properly nonified.

bindings/pyroot/pythonizations/python/ROOT/_application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from cppyy.gbl import gSystem, gInterpreter, gEnv
1515

16-
from libROOTPythonizations import InitApplication, InstallGUIEventInputHook
16+
from ROOT.libROOTPythonizations import InitApplication, InstallGUIEventInputHook
1717

1818

1919
class PyROOTApplication(object):

bindings/pyroot/pythonizations/python/ROOT/_facade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import libcppyy as cppyy_backend
88
from cppyy import gbl as gbl_namespace
99
from cppyy import cppdef, include
10-
from libROOTPythonizations import gROOT
10+
from ROOT.libROOTPythonizations import gROOT
1111
from cppyy.gbl import gSystem
1212
import cppyy.ll
1313

bindings/pyroot/pythonizations/python/ROOT/_pythonization/_cppinstance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
################################################################################
1010

1111
import libcppyy
12-
from libROOTPythonizations import AddCPPInstancePickling
12+
from ROOT.libROOTPythonizations import AddCPPInstancePickling
1313

1414
def pythonize_cppinstance():
1515
klass = libcppyy.CPPInstance

bindings/pyroot/pythonizations/python/ROOT/_pythonization/_generic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# For the list of contributors see $ROOTSYS/README/CREDITS. #
99
################################################################################
1010

11-
from libROOTPythonizations import AddPrettyPrintingPyz
11+
from ROOT.libROOTPythonizations import AddPrettyPrintingPyz
1212

1313
def _add_getitem_checked(klass):
1414
# Parameters:

bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tclass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
################################################################################
1010

1111
import cppyy
12-
from libROOTPythonizations import AddTClassDynamicCastPyz
12+
from ROOT.libROOTPythonizations import AddTClassDynamicCastPyz
1313

1414

1515
def pythonize_tclass():

bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tmva/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from .. import pythonization
1818

19-
from libROOTPythonizations import gROOT
19+
from ROOT.libROOTPythonizations import gROOT
2020

2121
from ._factory import Factory
2222
from ._dataloader import DataLoader

0 commit comments

Comments
 (0)