dd4hep: avoid IndexError in setup_run_environment (#41051)

Some environments may have `dd4hep` as a concretized package without having it installed (yet). For those environments, `dd4hep` has property `libs` that is an empty list. Nevertheless, it can be added to a run environment (for example in case `dd4hep` is part of an environment). This results in an IndexError:
```
==> Warning: couldn't load runtime environment due to IndexError: list index out of range
```
To avoid the IndexError, only prepend the `dd4hep` libs if there are actually libs found.
This commit is contained in:
Wouter Deconinck 2023-11-14 02:25:56 -06:00 committed by GitHub
parent 769474fcb0
commit c264cf12a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -254,7 +254,8 @@ def setup_run_environment(self, env):
env.set("DD4HEP", self.prefix.examples)
env.set("DD4hep_DIR", self.prefix)
env.set("DD4hep_ROOT", self.prefix)
env.prepend_path("LD_LIBRARY_PATH", self.libs.directories[0])
if len(self.libs.directories) > 0:
env.prepend_path("LD_LIBRARY_PATH", self.libs.directories[0])
def url_for_version(self, version):
# dd4hep releases are dashes and padded with a leading zero