conda-forge / root-feedstock

A conda-smithy repository for root.
BSD 3-Clause "New" or "Revised" License
28 stars 24 forks source link

Strange errors when installing ROOT from conda in a github action pipeline #272

Open acampove opened 6 hours ago

acampove commented 6 hours ago

Solution to issue cannot be found in the documentation.

Issue

Hi,

I am trying to run a pipeline in github which uses ROOT as a dependency before running the tests with pytest. The job seems to be failing with messages like:

 /usr/share/miniconda/lib/python3.12/site-packages/ROOT/_pythonization/_rdataframe.py:508: TypeError
----------------------------- Captured stderr call -----------------------------
In file included from input_line_44:1:
/usr/share/miniconda/include/CPyCppyy/API.h:15:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
In file included from input_line_45:1:
/usr/share/miniconda/include/CPyCppyy/API.h:15:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
_________________________________ test_predict _________________________________
    def test_predict():
        '''
        Will test probability prediction
        '''
        cfg   = ut.get_config('ml/tests/train_mva.yaml')

>       df_ft, l_lab = _get_train_input()
tests/ml/test_cv_classifier.py:90: 

which I do not understand. When I run the same tests in my laptop, also using this version of ROOT, from a virtual environment, I do not see any problem. The YAML file where the actions are defined reads:

name: Publish Python 🐍 distribution πŸ“¦ to PyPI and TestPyPI
on: push
jobs:
  build:
    name   : Build distribution
    runs-on: ubuntu-latest
    strategy:
      max-parallel: 5
    steps:
    - uses: actions/checkout@v4
    - name: Set up Python 3.10
      uses: actions/setup-python@v3
      with:
        python-version: '3.10'
    - name: Add conda to system path
      run: |
        echo $CONDA/bin >> $GITHUB_PATH
    - name: Install dependencies
      run: |
        conda install conda-forge::root
    #-----------
    - name: Test
      run: |
          pip install .[dev]
          pytest tests/arrays
          pytest tests/generic
          pytest tests/logging
          pytest tests/stats
          pytest tests/text
    #-----------
    - name: Build a binary wheel and a source tarball
      run: python3 -m build
    #-----------
    - name: Store the distribution packages
      uses: actions/upload-artifact@v4
      with:
        name: python-package-distributions
        path: dist/
  publish-to-pypi:
    name: >-
      Publish Python 🐍 distribution πŸ“¦ to PyPI
    if: startsWith(github.ref, 'refs/tags/')  # only publish to PyPI on tag pushes
    needs:
    - build
    runs-on: ubuntu-latest
    environment:
      name: pypi
      url: https://pypi.org/p/<package-name>  # Replace <package-name> with your PyPI project name
    permissions:
      id-token: write  # IMPORTANT: mandatory for trusted publishing
    steps:
    - name: Download all the dists
      uses: actions/download-artifact@v4
      with:
        name: python-package-distributions
        path: dist/
    - name: Publish distribution πŸ“¦ to PyPI
      uses: pypa/gh-action-pypi-publish@release/v1
  github-release:
    name: >-
      Sign the Python 🐍 distribution πŸ“¦ with Sigstore
      and upload them to GitHub Release
    needs:
    - publish-to-pypi
    runs-on: ubuntu-latest
    permissions:
      contents: write  # IMPORTANT: mandatory for making GitHub Releases
      id-token: write  # IMPORTANT: mandatory for sigstore
    steps:
    - name: Download all the dists
      uses: actions/download-artifact@v4
      with:
        name: python-package-distributions
        path: dist/
    - name: Sign the dists with Sigstore
      uses: sigstore/gh-action-sigstore-python@v3.0.0
      with:
        inputs: >-
          ./dist/*.tar.gz
          ./dist/*.whl
    - name: Create GitHub Release
      env:
        GITHUB_TOKEN: ${{ github.token }}
      run: >-
        gh release create
        '${{ github.ref_name }}'
        --repo '${{ github.repository }}'
        --notes ""
    - name: Upload artifact signatures to GitHub Release
      env:
        GITHUB_TOKEN: ${{ github.token }}
      # Upload to GitHub Release using the `gh` CLI.
      # `dist/` contains the built packages, and the
      # sigstore-produced signatures and certificates.
      run: >-
        gh release upload
        '${{ github.ref_name }}' dist/**
        --repo '${{ github.repository }}'

Installed packages

I only install ROOT and pytest, as is specified in the workflow file shown. I also install my personal project, which has these dependencies:

dependencies= [
'zfit', 
'logzero',
'PyYAML', 
'scipy', 
'awkward', 
'tqdm', 
'joblib', 
'scikit-learn', 
'toml', 
'numpy', 
'matplotlib', 
'mplhep', 
'hist[plot]',
'polars', 
'pandas']

[project.optional-dependencies]
dev  = ['pytest']

Environment info

I cannot issue `conda info` because the jobs are running in a github pipeline, however that pipeline is setup with the lines:

name: Publish Python 🐍 distribution πŸ“¦ to PyPI and TestPyPI
on: push
jobs:
  build:
    name   : Build distribution
    runs-on: ubuntu-latest
    strategy:
      max-parallel: 5
    steps:
    - uses: actions/checkout@v4
    - name: Set up Python 3.10
      uses: actions/setup-python@v3
      with:
        python-version: '3.10'
    - name: Add conda to system path
      run: |
        echo $CONDA/bin >> $GITHUB_PATH
    - name: Install dependencies
      run: |
        conda install conda-forge::root
    #-----------

which most likely tells you the relevant part.
acampove commented 5 hours ago

Another update, I see:

==================================== ERRORS ====================================
_________________ ERROR collecting tests/stats/test_fitter.py __________________
tests/stats/test_fitter.py:9: in <module>
    import ROOT
/usr/share/miniconda/lib/python3.12/site-packages/ROOT/__init__.py:25: in <module>
    import cppyy
/usr/share/miniconda/lib/python3.12/site-packages/cppyy/__init__.py:81: in <module>
    from ._cpython_cppyy import *
/usr/share/miniconda/lib/python3.12/site-packages/cppyy/_cpython_cppyy.py:21: in <module>
    c = loader.load_cpp_backend()
/usr/share/miniconda/lib/python3.12/site-packages/cppyy_backend/loader.py:79: in load_cpp_backend
    raise RuntimeError("could not load cppyy_backend library")
E   RuntimeError: could not load cppyy_backend library

If I add to the yaml file the compiler and cppyy as dependencies:

      run: |
        echo $CONDA/bin >> $GITHUB_PATH
    - name: Install dependencies
      run: |
        conda install conda-forge::gxx
        conda install conda-forge::cppyy
        conda install conda-forge::root