CERN ROOT on Windows

Try one or the other. I’ll try myself as soon as I can. And I’ll most probably change this on Windows only

I removed the copy.

Adding /bin/cppyy to %PATH% has no effect.

When I add it to %PYTHONPATH% and call root --notebook I immediately get the error

 Traceback (most recent call last):
  File "<frozen runpy>", line 15, in <module>
  File "<frozen importlib.util>", line 15, in <module>
  File "C:\Root\root-6.40.02\bin\cppyy\types.py", line 4, in <module>
    import cppyy
  File "C:\Root\root-6.40.02\bin\cppyy\__init__.py", line 53, in <module>
    import ctypes
  File "C:\Python314\Lib\ctypes\__init__.py", line 5, in <module>
    import sysconfig as _sysconfig
  File "C:\Python314\Lib\sysconfig\__init__.py", line 5, in <module>
    import threading
  File "C:\Python314\Lib\threading.py", line 9, in <module>
    from _weakrefset import WeakSet
  File "C:\Python314\Lib\_weakrefset.py", line 6, in <module>
    from types import GenericAlias
ImportError: cannot import name 'GenericAlias' from partially initialized module 'types' (most likely due to a circular import) (C:\Root\root-6.40.02\bin\cppyy\types.py)

OK, so for the time being, just keep libcppyy.pyd in the bin directory. I’ll change this behavior for the next releases.

Thank you so much for your help!
Now I will play around with interactive C++ and see what I can do with it.
:heart:

You’re very welcome, and have fun!

Here are the details of the installation procedure that finally worked:

  1. Install Python

    • Download and install Miniconda3-py314_26.5.3-2-Windows-x86_64.exe
      from Index of /miniconda . No need to add to PATH.
    • Open an Anaconda Prompt and run the command
      pip install notebook metakernel
  2. Install ROOT

    • Download, unzip and untar root_v6.40.02.source.tar.gz from Release 64002 - ROOT .
    • Move and rename root-6.40.02 as C:\Root\root-6.40.02-source .
    • Apply the patch below.
    • Open an Anaconda Prompt and run the installation script below.
  3. Launch Jupyter notebook with ROOT kernel

    • Open an Anaconda Prompt and run the commands
      call C:\Root\root-6.40.02\bin\thisroot.bat
      root --notebook

Installation script:

@echo Start time: %time%
set SOURCE_DIR=C:/Root/root-6.40.02-source
set BUILD_DIR=C:/Root/root-6.40.02-build
set INSTALL_DIR=C:/Root/root-6.40.02
if exist "%BUILD_DIR%" rmdir /s /q "%BUILD_DIR%"
if exist "%INSTALL_DIR%" rmdir /s /q "%INSTALL_DIR%"
cmake -S "%SOURCE_DIR%" -B "%BUILD_DIR%" -G "Visual Studio 17 2022" ^
    -A x64 -T host=x64 -Wno-author -DCMAKE_CXX_STANDARD=20 ^
    -Dbuiltin_freetype=ON -Dbuiltin_ftgl=ON -Dbuiltin_gif=ON ^
    -Dbuiltin_gl2ps=ON -Dbuiltin_jpeg=ON -Dbuiltin_png=ON ^
    -Dbuiltin_gtest=ON -Dbuiltin_lzma=ON -Dbuiltin_lz4=ON ^
    -Dbuiltin_pcre=ON -Dbuiltin_tiff=ON -Dbuiltin_unuran=ON ^
    -Dbuiltin_xxhash=ON -Dbuiltin_zlib=ON -Dbuiltin_zstd=ON 
cmake --build "%BUILD_DIR%" --config Release
cmake --install "%BUILD_DIR%" --prefix "%INSTALL_DIR%"
copy "%INSTALL_DIR%"\bin\cppyy\libcppyy.pyd "%INSTALL_DIR%"\bin
@echo Finish time: %time%

Patch:

Patch (proposed by Gemini):

Replace the code block that starts at line 604 in  C:\Root\root-6.40.02-source\CMakeLists.txt  with the following

#---Populate the configure arguments returned by 'root-config --config'--------------------------
get_cmake_property(variables CACHE_VARIABLES)
foreach(var ${variables})
  # FIX: Use NOT "${${var}}" STREQUAL "" with quotes, or simply check if the variable is defined and not empty
  if((var MATCHES "_(LIBRARIES|LIBRARY|INCLUDE|VERSION)") AND
     (DEFINED ${var}) AND (NOT "${${var}}" STREQUAL "") AND
     (NOT var MATCHES "NOTFOUND")) # FIX: var should not have ${} here either if checking the name
    if (var MATCHES "^QT_")
      # filter out the very long list of Qt libraries and include dirs
      if (var MATCHES "(QT_LIBRARY_DIR|QT_QTCORE_INCLUDE_DIR)")
        set(ROOT_CONFIGARGS "${ROOT_CONFIGARGS}${var}=${${var}} ")
      endif()
    else()
      if ((NOT var MATCHES "_(DOCS|TESTS|INSTALL)") AND (NOT var MATCHES "^_")
          AND NOT(var MATCHES "^CMAKE_PROJECT_VERSION") # Created by the 'latest' call to project()
          AND NOT(var MATCHES "^CMAKE_CACHE_") # related to previous CMake invocation eg CMAKE_CACHE_MAJOR_VERSION
          AND NOT(var MATCHES "^ROOT_.*_LIBRARY$")) # Created for users in ROOTConfig.cmake
        set(ROOT_CONFIGARGS "${ROOT_CONFIGARGS}${var}=${${var}} ")
      endif()