Skip to content

Commit

Permalink
[PyROOT] Merge PyROOTWrapper with PyROOTModule
Browse files Browse the repository at this point in the history
The PyROOTWrapper is a small piece of code that is only used in
PyROOTModuce.cxx, so I don't think it needs its own translation unit.
  • Loading branch information
guitargeek committed Nov 8, 2024
1 parent 79548a4 commit cdcdc53
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 71 deletions.
1 change: 0 additions & 1 deletion bindings/pyroot/pythonizations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ set(py_sources

set(cpp_sources
src/PyROOTModule.cxx
src/PyROOTWrapper.cxx
src/RPyROOTApplication.cxx
src/GenericPyz.cxx
src/TClassPyz.cxx
Expand Down
27 changes: 23 additions & 4 deletions bindings/pyroot/pythonizations/src/PyROOTModule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

// Bindings
#include "PyROOTPythonize.h"
#include "PyROOTWrapper.h"
#include "RPyROOTApplication.h"
#include "TMemoryRegulator.h"

// Cppyy
#include "CPyCppyy/API.h"
Expand All @@ -34,7 +34,7 @@

namespace PyROOT {

PyObject *gRootModule = nullptr;
R__EXTERN PyObject *gRootModule = nullptr;

Check warning on line 37 in bindings/pyroot/pythonizations/src/PyROOTModule.cxx

View workflow job for this annotation

GitHub Actions / mac13 ARM64 LLVM_ENABLE_ASSERTIONS=On, builtin_zlib=ON

'extern' variable has an initializer [-Wextern-initializer]

Check warning on line 37 in bindings/pyroot/pythonizations/src/PyROOTModule.cxx

View workflow job for this annotation

GitHub Actions / fedora40 LLVM_ENABLE_ASSERTIONS=On, CMAKE_CXX_STANDARD=20

‘gRootModule’ initialized and declared ‘extern’

Check warning on line 37 in bindings/pyroot/pythonizations/src/PyROOTModule.cxx

View workflow job for this annotation

GitHub Actions / mac15 ARM64 LLVM_ENABLE_ASSERTIONS=On, CMAKE_CXX_STANDARD=20

'extern' variable has an initializer [-Wextern-initializer]

Check warning on line 37 in bindings/pyroot/pythonizations/src/PyROOTModule.cxx

View workflow job for this annotation

GitHub Actions / fedora41 LLVM_ENABLE_ASSERTIONS=On

‘gRootModule’ initialized and declared ‘extern’

Check warning on line 37 in bindings/pyroot/pythonizations/src/PyROOTModule.cxx

View workflow job for this annotation

GitHub Actions / mac-beta ARM64 LLVM_ENABLE_ASSERTIONS=On, CMAKE_CXX_STANDARD=20

'extern' variable has an initializer [-Wextern-initializer]

Check warning on line 37 in bindings/pyroot/pythonizations/src/PyROOTModule.cxx

View workflow job for this annotation

GitHub Actions / alma8 LLVM_ENABLE_ASSERTIONS=On

‘gRootModule’ initialized and declared ‘extern’

Check warning on line 37 in bindings/pyroot/pythonizations/src/PyROOTModule.cxx

View workflow job for this annotation

GitHub Actions / alma9 LLVM_ENABLE_ASSERTIONS=On, CMAKE_BUILD_TYPE=Debug

‘gRootModule’ initialized and declared ‘extern’

Check warning on line 37 in bindings/pyroot/pythonizations/src/PyROOTModule.cxx

View workflow job for this annotation

GitHub Actions / ubuntu20 LLVM_ENABLE_ASSERTIONS=On

‘gRootModule’ initialized and declared ‘extern’

Check warning on line 37 in bindings/pyroot/pythonizations/src/PyROOTModule.cxx

View workflow job for this annotation

GitHub Actions / ubuntu22 imt=Off, LLVM_ENABLE_ASSERTIONS=On, CMAKE_BUILD_TYPE=Debug

‘gRootModule’ initialized and declared ‘extern’

Check warning on line 37 in bindings/pyroot/pythonizations/src/PyROOTModule.cxx

View workflow job for this annotation

GitHub Actions / ubuntu2404 LLVM_ENABLE_ASSERTIONS=On, CMAKE_BUILD_TYPE=Debug

‘gRootModule’ initialized and declared ‘extern’

Check warning on line 37 in bindings/pyroot/pythonizations/src/PyROOTModule.cxx

View workflow job for this annotation

GitHub Actions / debian125 LLVM_ENABLE_ASSERTIONS=On, CMAKE_CXX_STANDARD=20

‘gRootModule’ initialized and declared ‘extern’

Check warning on line 37 in bindings/pyroot/pythonizations/src/PyROOTModule.cxx

View workflow job for this annotation

GitHub Actions / alma9 modules_off runtime_cxxmodules=Off

‘gRootModule’ initialized and declared ‘extern’

Check warning on line 37 in bindings/pyroot/pythonizations/src/PyROOTModule.cxx

View workflow job for this annotation

GitHub Actions / alma9 march_native CMAKE_BUILD_TYPE=RelWithDebInfo, CMAKE_CXX_FLAGS=-march=native, CMAKE_C_FLAGS=-march=native, fortran=OFF

‘gRootModule’ initialized and declared ‘extern’

Check warning on line 37 in bindings/pyroot/pythonizations/src/PyROOTModule.cxx

View workflow job for this annotation

GitHub Actions / alma9-clang clang LLVM_ENABLE_ASSERTIONS=On, CMAKE_C_COMPILER=clang, CMAKE_CXX_COMPILER=clang++

'extern' variable has an initializer [-Wextern-initializer]

PyObject *RegisterConverterAlias(PyObject * /*self*/, PyObject *args)
{
Expand Down Expand Up @@ -62,6 +62,20 @@ PyObject *RegisterExecutorAlias(PyObject * /*self*/, PyObject *args)

} // namespace PyROOT

namespace {

PyROOT::RegulatorCleanup &GetRegulatorCleanup()
{
// The object is thread-local because it can happen that we call into
// C++ code (from the PyROOT CPython extension, from CPyCppyy or from cling)
// from different Python threads. A notable example is within a distributed
// RDataFrame application running on Dask.
thread_local PyROOT::RegulatorCleanup m;
return m;
}

} // namespace

// Methods offered by the interface
static PyMethodDef gPyROOTMethods[] = {
{(char *)"AddCPPInstancePickling", (PyCFunction)PyROOT::AddCPPInstancePickling, METH_VARARGS,
Expand Down Expand Up @@ -144,8 +158,13 @@ extern "C" PyObject *PyInit_libROOTPythonizations()
// keep gRootModule, but do not increase its reference count even as it is borrowed,
// or a self-referencing cycle would be created

// setup PyROOT
PyROOT::Init();
// Initialize and acquire the GIL to allow for threading in ROOT
#if PY_VERSION_HEX < 0x03090000
PyEval_InitThreads();
#endif

// Memory management
gROOT->GetListOfCleanups()->Add(&GetRegulatorCleanup());

// signal policy: don't abort interpreter in interactive mode
CallContext::SetGlobalSignalPolicy(!gROOT->IsBatch());
Expand Down
42 changes: 0 additions & 42 deletions bindings/pyroot/pythonizations/src/PyROOTWrapper.cxx

This file was deleted.

24 changes: 0 additions & 24 deletions bindings/pyroot/pythonizations/src/PyROOTWrapper.h

This file was deleted.

0 comments on commit cdcdc53

Please sign in to comment.