Skip to content

Commit 98718ca

Browse files
committed
[PyROOT][tutorials] Add rootlogon for Python tutorials
Launching the Python tutorials from the 'tutorials/launcher.py' module injected the "__main__" namespace in the tutorial itself. In general it is not a problem, but it can sometimes hide errors like the one fixed by #10177 . Using a rootlogon file serves the same purpose and the tutorials can thus be launched by simply calling 'python tutorialname.py'.
1 parent 2c72dac commit 98718ca

File tree

3 files changed

+8
-40
lines changed

3 files changed

+8
-40
lines changed

tutorials/.rootlogon.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""rootlogon module for the Python tutorials. Disables the graphics."""
2+
import ROOT
3+
ROOT.gROOT.SetBatch(True)
4+
ROOT.gROOT.SetWebDisplay("batch")

tutorials/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,9 @@ endforeach()
592592
#---Python tutorials-----------------------------------------------------
593593
if(ROOT_pyroot_FOUND)
594594

595+
# Copy .rootlogon.py file into the build directory. It disables graphics for the Python tutorials
596+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/.rootlogon.py ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
597+
595598
file(GLOB_RECURSE pytutorials RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py)
596599

597600
# Now python-specific vetos:
@@ -762,7 +765,7 @@ if(ROOT_pyroot_FOUND)
762765
endforeach()
763766

764767
ROOT_ADD_TEST(${tutorial_name}
765-
COMMAND ${PYTHON_EXECUTABLE_Development_Main} ${CMAKE_CURRENT_SOURCE_DIR}/launcher.py ${CMAKE_CURRENT_SOURCE_DIR}/${t}
768+
COMMAND ${PYTHON_EXECUTABLE_Development_Main} ${CMAKE_CURRENT_SOURCE_DIR}/${t}
766769
PASSRC ${rc} FAILREGEX "Error in" ": error:" "segmentation violation"
767770
LABELS ${labels}
768771
DEPENDS ${${tname}-depends}

tutorials/launcher.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)