From 690c9cb4fb54455690dd3a557855c6cffd018603 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Fri, 16 Jan 2026 13:39:38 +0100 Subject: [PATCH] [Python] Fix ROOT include directory resolution for Python wheels As of commit a5b1ed9, ROOT became smarter about finding the include path in the install tree, inferring the correct relative path from $ROOTSYS and the CMAKE_INSTALL_INCLUDEDIR variable at build time. Before, that only happened for `gnuinstall=ON`, but now it always happens. However, for the Python wheel, we are breaking the assumptions that ROOT makes by moving around directories in the install tree. Fortunately, we are moving directories around such that in the end, it has same structure as the build tree. Hence, we put the build tree marker in the Python package, so ROOT thinks the relative resource paths from the build tree apply. --- setup.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index be8aa84f0eaeb..1d7e7ca865c45 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ INSTALL_DIR = tempfile.mkdtemp() # Name given to an internal directory within the build directory -# used to mimick the structure of the target installation directory +# used to mimic the structure of the target installation directory # in the user Python environment, usually named "site-packages" ROOT_BUILD_INTERNAL_DIRNAME = "mock_site_packages" @@ -147,6 +147,20 @@ def run(self): self.copy_tree(os.path.join(INSTALL_DIR, "tutorials"), os.path.join(root_package_dir, "tutorials")) self.copy_file(os.path.join(INSTALL_DIR, "LICENSE"), os.path.join(root_package_dir, "LICENSE")) + # As of commit [1], ROOT became smarter about finding the include path + # in the install tree, inferring the correct relative path from + # $ROOTSYS and the CMAKE_INSTALL_INCLUDEDIR variable at build time. + # + # However, for the Python wheel, we are breaking the assumptions that + # ROOT makes by moving around directories in the install tree. + # Fortunately, we are moving directories around such that in the end, + # it has same structure as the build tree. Hence, we put the build tree + # marker in the Python package, so ROOT thinks the relative resource + # paths from the build tree apply. + # + # [1] https://github.com/root-project/root/commit/a5b1ed9 + pathlib.Path(os.path.join(root_package_dir, "lib/root-build-tree-marker")).touch() + def get_outputs(self): outputs = _install.get_outputs(self) return outputs