steps:
- powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
  displayName: Setup build environment
- script: |
    conda config --set always_yes yes --set changeps1 no
    conda info -a
    conda install -n base conda-libmamba-solver
    conda config --set solver libmamba
    conda create --name rdkit_build -c conda-forge --override-channels  $(python) ^
        libboost-python=(boost_version) ^
        libboost-python-devel=(boost_version) ^
        libboost=$(boost_version) ^
        libboost-devel=$(boost_version) ^
        numpy matplotlib cairo pillow eigen ^
        numpy=2.4 pandas=3 ^
        sphinx myst-parser ipython jupyter pytest nbval cmake 
    call activate rdkit_build
    conda config --env --add channels conda-forge 
    conda config --env --set channel_priority strict
  displayName: Install dependencies
- script: |
    set Boost_ROOT=
    mkdir build && cd build
    call activate rdkit_build
    cmake .. ^
    -G "Visual Studio 17 2022" ^
    -DCMAKE_BUILD_TYPE=Release ^
    -DRDK_INSTALL_INTREE=ON ^
    -DRDK_INSTALL_STATIC_LIBS=OFF ^
    -DRDK_BUILD_CPP_TESTS=ON ^
    -DRDK_BUILD_PYTHON_WRAPPERS=ON ^
    -DRDK_BUILD_COORDGEN_SUPPORT=ON ^
    -DRDK_BUILD_MAEPARSER_SUPPORT=ON ^
    -DRDK_OPTIMIZE_POPCNT=ON ^
    -DRDK_BUILD_TEST_GZIP=ON ^
    -DRDK_BUILD_FREESASA_SUPPORT=ON ^
    -DRDK_BUILD_AVALON_SUPPORT=ON ^
    -DRDK_BUILD_INCHI_SUPPORT=ON ^
    -DRDK_BUILD_YAEHMOP_SUPPORT=ON ^
    -DRDK_BUILD_XYZ2MOL_SUPPORT=ON ^
    -DRDK_BUILD_CAIRO_SUPPORT=ON ^
    -DRDK_BUILD_THREADSAFE_SSS=ON ^
    -DRDK_BUILD_SWIG_WRAPPERS=OFF ^
    -DRDK_BUILD_CFFI_LIB=ON ^
    -DRDK_SWIG_STATIC=OFF ^
    -DRDK_TEST_MULTITHREADED=ON ^
    -DCMAKE_INCLUDE_PATH=%CONDA_PREFIX%/Library/include ^
    -DCMAKE_LIBRARY_PATH="%CONDA_PREFIX%/Library/lib
  displayName: Configure build (Run CMake)
- script: |
    call activate rdkit_build
    cd build
    cmake --build . --config Release --target install -j $(number_of_cores)
  displayName: Build
- script: |
    call activate rdkit_build
    set RDBASE=%cd%
    set PYTHONPATH=%RDBASE%;%PYTHONPATH%
    set PATH=%RDBASE%\lib;%PATH%
    cd build
    ctest -C Release -j $(number_of_cores) --output-on-failure -T Test
  displayName: Run tests
- script: |
    call activate rdkit_build
    conda install -c conda-forge --override-channels  numpy=1.26 pandas=2.2
    set RDBASE=%cd%
    set PYTHONPATH=%RDBASE%;%PYTHONPATH%
    set PATH=%RDBASE%\lib;%PATH%
    cd build
    ctest -C Release -j $(number_of_cores) --output-on-failure -T Test
  displayName: Run with older numpy and pandas
- script: |
    call activate rdkit_build
    conda install -c conda-forge --override-channels  sphinx myst-parser
    set RDBASE=%cd%
    set PYTHONPATH=%RDBASE%;%PYTHONPATH%
    set PATH=%RDBASE%\lib;%PATH%
    cd Docs/Book
    make doctest
  displayName: Run documentation tests
- task: PublishTestResults@2
  inputs:
    testResultsFormat: 'CTest'
    testResultsFiles: 'build/Testing/*/Test.xml'
    testRunTitle: $(system.phasedisplayname)  CTest Test Run