Skip to content

Inconsistent lookup of compiled python modules

Consider the following example from GaudiExamples/CMakeLists.txt:

# Compiled python module
gaudi_add_python_module(PyExample
                        SOURCES src/PythonModule/Functions.cpp
                                src/PythonModule/PyExample.cpp
                        LINK Python::Python
                             Boost::python)

When using the build environment, the module can (or not) be imported like this:

$ Gaudi/run python
>>> import GaudiExamples
>>> GaudiExamples
<module 'GaudiExamples' from '/home/rmatev/stack/Gaudi/build.x86_64_v2-centos7-gcc11-dbg/python/GaudiExamples/__init__.py'>
>>> import PyExample
>>> PyExample
<module 'PyExample' from '/home/rmatev/stack/Gaudi/build.x86_64_v2-centos7-gcc11-dbg/GaudiExamples/PyExample.so'>
>>> import GaudiExamples.PyExample
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'GaudiExamples.PyExample'
>>>

When using an installation of Gaudi, the module can (or not) be imported like this, which is inconsistent:

$ LHCb/run python
>>> import GaudiExamples
>>> GaudiExamples
<module 'GaudiExamples' from '/home/rmatev/stack/Gaudi/InstallArea/x86_64_v2-centos7-gcc11-dbg/python/GaudiExamples/__init__.py'>
>>> import PyExample
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyExample'
>>> import GaudiExamples.PyExample
>>> GaudiExamples.PyExample
<module 'GaudiExamples.PyExample' from '/home/rmatev/stack/Gaudi/InstallArea/x86_64_v2-centos7-gcc11-dbg/python/GaudiExamples/PyExample.so'>
>>>
Edited by Rosen Matev
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information