CMake: don't create empty dir lib/bornagain
The command cmake ..
(with or without BA_PY_PACKAGE_VERSIONS
option) creates a directory lib/bornagain
. This directory remains empty throughout the build process. It has a disturbing consequence: If we build without Python API (pure cmake ..
with no BA_PY_PACKAGE_VERSIONS
) we would expect the Python command import bornagain
to fail. However, if the directory lib/bornagain
is present, then import bornagain
is executed silently. This can lead to confusion and to strange error reports like #188 (closed).
The strange behavior of Python's import statement can be demonstrated without building BornAgain:
$ rm -rf *
/G/sw/ba/build$ python3
Python 3.9.10 (main, Jan 16 2022, 17:12:18)
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bornagain
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'bornagain'
>>> quit()
/G/sw/ba/build$ mkdir lib
/G/sw/ba/build$ mkdir lib/bornagain
/G/sw/ba/build$ python3
Python 3.9.10 (main, Jan 16 2022, 17:12:18)
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bornagain
>>> repr(bornagain)
"<module 'bornagain' (namespace)>"
>>> help(bornagain)
The last statement yields
Help on package bornagain:
NAME
bornagain
PACKAGE CONTENTS
FILE
(built-in)
We can do nothing about Python's weird corners. But we should prevent lib/bornagain
from being created.
Edited by Wuttke, Joachim