Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use standard locations if the LD_LIBRARY_PATH or ROOTSYS are empty #1378

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion DDCore/python/dd4hepFactories.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ def __init__(self):
self.all_components = []

def scanPath(self):
ldp = os.environ['LD_LIBRARY_PATH'].split(':')
if os.getenv("LD_LIBRARY_PATH") is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ldp = os.environ['LD_LIBRARY_PATH'].split(':')
else:
ldp = ['/usr/lib64', '/usr/lib/', '/usr/local/lib', '/usr/lib64/root', '/usr/lib/root', '/usr/local/lib/root']
for p in ldp:
if len(p):
logger.info('+== Search component directory: ' + p)
Expand Down
30 changes: 24 additions & 6 deletions DDCore/python/dd4hep_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,24 @@ def compileAClick(dictionary, g4=True):
"""
from ROOT import gInterpreter, gSystem
import os.path
dd4hep = os.environ['DD4hepINSTALL']
inc = ' -I' + os.environ['ROOTSYS'] + '/include -I' + dd4hep + '/include '
lib = ' -L' + dd4hep + '/lib -lDDCore -lDDG4 -lDDSegmentation '
if os.getenv("DD4hepINSTALL") is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dd4hep = os.environ['DD4hepINSTALL']
else:
dd4hep = "/usr"
if os.getenv("ROOTSYS") is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rootsys = os.environ['ROOTSYS']
else:
rootsys = "/usr"

inc = ' -I' + rootsys + '/include -I' + dd4hep + '/include '
lib = ' -L' + dd4hep + '/lib64 ' + ' -L' + dd4hep + '/lib -lDDCore -lDDG4 -lDDSegmentation '
if g4:
geant4 = os.environ['G4INSTALL']
if os.getenv("G4INSTALL") is not None:
geant4 = os.environ['G4INSTALL']
else:
geant4 = "/usr"
inc = inc + ' -I' + geant4 + '/include/Geant4 -Wno-shadow -g -O0 '
lib = lib + ' -L' + geant4 + '/lib -L' + geant4 + '/lib64 -lG4event -lG4tracking -lG4particles '
lib = lib + ' -L' + geant4 + '/lib64 -L' + geant4 + '/lib -lG4event -lG4tracking -lG4particles '

gSystem.AddIncludePath(inc)
gSystem.AddLinkedLibs(lib)
Expand All @@ -50,7 +61,14 @@ def loaddd4hep():
import os
import sys
# Add ROOT to the python path in case it is not yet there....
sys.path.append(os.environ['ROOTSYS'] + os.sep + 'lib')
if os.getenv("ROOTSYS") is not None:
rootsys = os.environ['ROOTSYS']
else:
rootsys = "/usr"
sys.path.append(rootsys + os.sep + 'lib')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use os.path.join

sys.path.append(rootsys + os.sep + 'lib64')
sys.path.append(rootsys + os.sep + 'lib' + os.sep + 'root')
sys.path.append(rootsys + os.sep + 'lib64' + os.sep + 'root')
from ROOT import gSystem

import platform
Expand Down
5 changes: 3 additions & 2 deletions GaudiPluginService/src/PluginServiceV1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ namespace Gaudi {
const char sep = ':';
#endif
char* search_path = ::getenv( envVar );
if ( search_path ) {
if ( true ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Add a comment.

logger().debug( std::string( "searching factories in " ) + envVar );
std::string path( search_path );
std::string path;
if ( search_path ) path = std::string(search_path); else path="/usr/lib64:/usr/lib:/usr/local/lib";
andriish marked this conversation as resolved.
Show resolved Hide resolved
std::string::size_type pos = 0;
std::string::size_type newpos = 0;
while ( pos != std::string::npos ) {
Expand Down
2 changes: 1 addition & 1 deletion GaudiPluginService/src/PluginServiceV2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ namespace Gaudi {

std::string search_path;
const char* envPtr = std::getenv( envVar.c_str() );
if ( envPtr ) search_path = envPtr;
if ( envPtr ) search_path = envPtr; else search_path="/usr/lib64:/usr/lib:/usr/local/lib";
andriish marked this conversation as resolved.
Show resolved Hide resolved
if ( search_path.empty() ) {
return;
}
Expand Down
Loading