[cmake][PyROOT] Pythonizations in build directory don't get updated in incremental builds
Describe the bug
When you update the code in bindings/pyroot/pythonizations/python/ROOT/_pythonization and recompile ROOT, the corresponding build directory (root_build/lib/ROOT/_pythonization) doesn't get updated, and consequently also not the root_install/lib/ROOT/_pythonization directory when installing the build.
Expected behavior
It should be possible to update the Pythonizations in the source code, do an incremental build, and have them synced up in the build and install directories.
To Reproduce
- Compile ROOT from source
- Change any
_pythonizationfile in the source directory, e.g.bindings/pyroot/pythonizations/python/ROOT/_pythonization/__init__.py - Rebuild ROOT
- Open
root_build/lib/ROOT/_pythonization/__init__.py, and your changes won't be there
Setup
ROOT master on Arch Linux.
Additional context
- The issue was also encountered by @hahnjo (https://github.com/root-project/root/issues/11221#issuecomment-1222123312)
- It's important to fix this issue especially for students who work on the Pythonizations like in RooFit and TMVA, because it's quite confusing having to sync these
_pythonizationfiles manually in the development process.
I assigned @bellenot for now because Enric in off, but feel free to reassign!
I'm not sure how to achieve this with CMake, @bellenot ?
Now the python sources are inserted in a list, like:
set(py_sources
ROOT/__init__.py
ROOT/_application.py
...
and then that list is used to make sure we install their compiled version:
foreach(py_source ${py_sources})
install(CODE "execute_process(COMMAND ${python_executable} -m py_compile ${localruntimedir}/${py_source})")
install(CODE "execute_process(COMMAND ${python_executable} -O -m py_compile ${localruntimedir}/${py_source})")
endforeach()
but CMake does not copy them again to the build directory unless one does cmake ..
I got annoyed enough by this problem that I opened a PR: https://github.com/root-project/root/pull/11435