Skip to content

Commit 34066f7

Browse files
committed
Ensure external environment with Geant4+BDSIM is sourced when querying Geant4Environment.compiled
1 parent aa47b8b commit 34066f7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

xcoll/scattering_routines/geant4/environment.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,29 @@ def __init__(self):
2424
self._geant4 = None
2525
self._bdsim = None
2626
self._in_constructor = False
27+
self._geant4_sourced = False
28+
self._bdsim_sourced = False
2729
cmd = run(['which', 'geant4-config'], capture_output=True)
2830
if cmd.returncode == 0:
2931
path = FsPath(cmd.stdout.decode().strip())
3032
if path.exists():
3133
self._geant4 = path
34+
self._geant4_sourced = True
3235
cmd = run(['which', 'bdsim'], capture_output=True)
3336
if cmd.returncode == 0:
3437
path = FsPath(cmd.stdout.decode().strip())
3538
if path.exists():
3639
self._bdsim = path
40+
self._bdsim_sourced = True
3741

3842
@property
3943
def compiled(self):
4044
if self.geant4 is None or self.bdsim is None:
4145
return False
4246
so = list((self.data_dir).glob('g4interface.*so'))
43-
if len(so) == 1 and so[0].exists():
44-
return True
45-
return False
47+
if len(so) != 1 or not so[0].exists():
48+
return False
49+
return self._geant4_sourced and self._bdsim_sourced
4650

4751
def compile(self, verbose=True):
4852
# Check all dependencies

0 commit comments

Comments
 (0)