Skip to content

Commit 0e277c3

Browse files
committed
[PyROOT] Move CPython extensions into subdirectories
Closes #14917.
1 parent 9fc2c6c commit 0e277c3

File tree

11 files changed

+42
-21
lines changed

11 files changed

+42
-21
lines changed

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 libROOTPythonizations as _lib
22+
import ROOT.libROOTPythonizations as _lib
2323

2424

2525
class IOHandler(object):

bindings/pyroot/pythonizations/CMakeLists.txt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,19 @@ set(libname ROOTPythonizations)
169169

170170
add_library(${libname} SHARED ${cpp_sources})
171171

172+
# To make sure that the library also ends up in the right subdirectory in the
173+
# build directory tree.
174+
if(MSVC)
175+
set_target_properties(${libname}
176+
PROPERTIES
177+
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin/ROOT
178+
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin/ROOT
179+
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_BINARY_DIR}/bin/ROOT
180+
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR}/bin/ROOT)
181+
else()
182+
set_target_properties(${libname} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/ROOT)
183+
endif()
184+
172185
# Insert the ROOTPythonizationsPySources in the dependency graph
173186
add_dependencies(${libname} ROOTPythonizationsPySources)
174187

@@ -212,16 +225,16 @@ target_link_libraries(PyROOT INTERFACE cppyy_backend cppyy ROOTPythonizations)
212225

213226
# Install library
214227
install(TARGETS ${libname} EXPORT ${CMAKE_PROJECT_NAME}Exports
215-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
216-
LIBRARY DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries
217-
ARCHIVE DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries)
228+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/ROOT COMPONENT libraries
229+
LIBRARY DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/ROOT COMPONENT libraries
230+
ARCHIVE DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/ROOT COMPONENT libraries)
218231

219232
# Install meta-target PyROOT3 (INTERFACE library)
220233
# Install library
221234
install(TARGETS PyROOT EXPORT ${CMAKE_PROJECT_NAME}Exports
222-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries
223-
LIBRARY DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries
224-
ARCHIVE DESTINATION ${CMAKE_INSTALL_PYTHONDIR} COMPONENT libraries)
235+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/ROOT COMPONENT libraries
236+
LIBRARY DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/ROOT COMPONENT libraries
237+
ARCHIVE DESTINATION ${CMAKE_INSTALL_PYTHONDIR}/ROOT COMPONENT libraries)
225238

226239
# Install Python sources and bytecode
227240
install(DIRECTORY ${localruntimedir}/ROOT

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,31 @@
88
# For the list of contributors see $ROOTSYS/README/CREDITS. #
99
################################################################################
1010

11-
from os import environ
11+
import importlib
12+
import os
13+
import sys
1214

1315
# Prevent cppyy's check for the PCH
14-
environ["CLING_STANDARD_PCH"] = "none"
16+
os.environ["CLING_STANDARD_PCH"] = "none"
1517

1618
# Prevent cppyy's check for extra header directory
17-
environ["CPPYY_API_PATH"] = "none"
19+
os.environ["CPPYY_API_PATH"] = "none"
1820

1921
# Prevent cppyy from filtering ROOT libraries
20-
environ["CPPYY_NO_ROOT_FILTER"] = "1"
22+
os.environ["CPPYY_NO_ROOT_FILTER"] = "1"
23+
24+
# The libROOTPythonizations CPython extension is also in the directory of the
25+
# ROOT Python module, so we need to add out directory to the seach path (only
26+
# needed on Windows)
27+
if 'win32' in sys.platform:
28+
root_module_path = os.path.dirname(__file__)
29+
os.add_dll_directory(root_module_path)
30+
os.add_dll_directory(os.path.dirname(root_module_path))
2131

2232
# Do setup specific to AddressSanitizer environments
2333
from . import _asan
2434

2535
import cppyy
26-
import sys, importlib
27-
import libROOTPythonizations
2836

2937
# Build cache of commonly used python strings (the cache is python intern, so
3038
# all strings are shared python-wide, not just in PyROOT).

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
@@ -173,7 +173,7 @@ def _register_converters_and_executors(self):
173173
"Double32_t&": "double&",
174174
}
175175

176-
from libROOTPythonizations import CPyCppyyRegisterConverterAlias, CPyCppyyRegisterExecutorAlias
176+
from ROOT.libROOTPythonizations import CPyCppyyRegisterConverterAlias, CPyCppyyRegisterExecutorAlias
177177

178178
for name, target in converter_aliases.items():
179179
CPyCppyyRegisterConverterAlias(name, target)

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

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

1111
def pythonize_cppinstance():
1212
import cppyy
13-
from libROOTPythonizations import AddCPPInstancePickling
13+
from ROOT.libROOTPythonizations import AddCPPInstancePickling
1414

1515
klass = cppyy._backend.CPPInstance
1616

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/_rdf_namespace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def _rdataframe(local_rdf, distributed_rdf):
9494

9595
def rdataframe(*args, **kwargs):
9696
import ROOT
97-
from libROOTPythonizations import PyObjRefCounterAsStdAny
97+
from ROOT.libROOTPythonizations import PyObjRefCounterAsStdAny
9898

9999
if kwargs.get("executor", None) is not None:
100100
rdf = distributed_rdf(*args, **kwargs)

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/_tobject.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 AddTObjectEqNePyz
11+
from ROOT.libROOTPythonizations import AddTObjectEqNePyz
1212
import cppyy
1313

1414
# Searching

0 commit comments

Comments
 (0)