root icon indicating copy to clipboard operation
root copied to clipboard

[cmake][PyROOT] Pythonizations in build directory don't get updated in incremental builds

Open guitargeek opened this issue 3 years ago • 2 comments

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

  1. Compile ROOT from source
  2. Change any _pythonization file in the source directory, e.g. bindings/pyroot/pythonizations/python/ROOT/_pythonization/__init__.py
  3. Rebuild ROOT
  4. 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 _pythonization files manually in the development process.

guitargeek avatar Aug 22 '22 10:08 guitargeek

I assigned @bellenot for now because Enric in off, but feel free to reassign!

guitargeek avatar Aug 22 '22 10:08 guitargeek

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 ..

etejedor avatar Aug 24 '22 15:08 etejedor

I got annoyed enough by this problem that I opened a PR: https://github.com/root-project/root/pull/11435

guitargeek avatar Sep 26 '22 18:09 guitargeek