Documentation of rootlogon.py?

Hi, I’ve found some forum posts talking about a rootlogon.py file that you can keep in ~/ that will behave like the rootlogon.C file that ROOT runs when it opens up. I couldn’t find any real documentation about it, nor a fully detailed forum post. I tried creating such a file, but it wasn’t run when doing “import ROOT”.

Can someone answer these questions:

  • is this the PyROOT equivalent of rootlogon.C?
  • can you control where the file is found with a .rootrc setting?
  • can I just make rootlogon.py run my usual rootlogon.C file?
  • under what conditions is a rootlogon.py file actually executed, is it upon “import ROOT”?

Thanks,
Jean-François

Jean-François,

“import ROOT” does not load ROOT just yet: to allow ‘batch’ mode to be set programmatically and to allow ignoring CLI arguments. First (non-gROOT) ROOT use runs ~/rootlogon.py, unless ‘-n’ is defined in sys.argv (just like with root.exe).

rootlogon.py is imported, not execfiled(), since this gives more control within the file.

If ~/rootlogon.py is imported, rootlogon.C is ignored. The assumption here is indeed that rootlogon.C can be loaded from rootlogon.py if that is desired, so yes you can do this with gApplication.ExecuteFile().

If rootlogon.C it to be loaded, it is picked up from a couple of standard places, in order, incl. gRootDir/etc. All rootlogon.C’s found are executed.

rootlogon.py is only searched for in the home directory. You can get further control by importing your own custom-named settings module inside rootlogon.py, which will subsequently be found through PYTHONPATH.

rootrc is not checked.

Contrary to python’s startup file, rootlogon is executed both in batch and interactive.

I don’t think it is a widely used feature. Let me know if you need any changes.

Cheers,
Wim