gimli-org / gimli

Geophysical Inversion and Modeling Library :earth_africa:
https://www.pygimli.org
Other
383 stars 137 forks source link

Running pyGIMLi on GHA fails to import #743

Closed prisae closed 4 months ago

prisae commented 4 months ago

Problem description

I try to run tests involving pyGIMLi on the GitHub Action CI. However, I struggle to get it running.

Your environment

Operating system: GHA, ubuntu-latest Python version: 3.11 (but same happened with 3.9, 3.10) pyGIMLi version: I cannot import it, so pygimli.Report() or pygimli.__version__ does not work. scooby pygimli pgcore, however, yields

--------------------------------------------------------------------------------
  Date: Mon Jul 01 08:24:15 2024 UTC
                OS : Linux (Ubuntu 22.04)
            CPU(s) : 4
           Machine : x86_64
      Architecture : 64bit
       Environment : Python
  Python 3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:36:13) [GCC
  12.3.0]
           pygimli : 1.5.1
            pgcore : 1.5.0
             numpy : 1.26.4
             scipy : 1.14.0
        matplotlib : 3.8.4
            scooby : 0.10.0
--------------------------------------------------------------------------------

Also, conda list yields

pgcore                    1.5.0           np126py311h086f6c2_0    gimli
pygimli                   1.5.1                      py_0    gimli

Way of installation: conda

Steps to reproduce

The code I tested it with is here: https://github.com/emsig/emg3d/tree/testing

It contains only one file, .github/workflows/linux.yml with the following content:

name: linux

on:
  push:
    branches:
      - testing

defaults:
  run:
    shell: bash -l {0}

jobs:
  test:
    name: test-pyGIMLi-import
    runs-on: ubuntu-latest

    steps:

      - name: Setup miniconda
        uses: conda-incubator/setup-miniconda@v3
        with:
          auto-update-conda: true
          python-version: "3.11"
          miniforge-version: "latest"
          miniforge-variant: Mambaforge
          use-mamba: true

      - name: Conda settings
        run: |
          conda config --set always_yes yes --set changeps1 no
          conda config --show-sources
          conda config --show
          conda info -a

      - name: Install pyGIMLi
        run: conda install -c gimli -c conda-forge pygimli scooby

      - name: Conda list
        run: conda list

      - name: Which Python
        run: which python

      - name: Scooby pyGIMLi
        run: scooby pygimli pgcore

      - name: Import pyGIMLi
        run: python -c 'import pygimli; print(pygimli.Report())'

Expected behavior

That the command python -c 'import pygimli; print(pygimli.Report())' would work.

Actual behavior

ERROR: cannot import the library '_pygimli_'.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/runner/miniconda3/envs/test/lib/python3.11/site-packages/pygimli/__init__.py", line 8, in <module>
    from .core.decorators import (renamed, singleton, moduleProperty,
  File "/home/runner/miniconda3/envs/test/lib/python3.11/site-packages/pygimli/core/__init__.py", line 14, in <module>
libcholmod.so.3: cannot open shared object file: No such file or directory
    from .base import (isInt, isScalar, isIterable, isArray, isPos, isR3Array,
  File "/home/runner/miniconda3/envs/test/lib/python3.11/site-packages/pygimli/core/base.py", line 7, in <module>
    from .core import (RVector3, R3Vector, RMatrix)
ImportError: cannot import name 'RVector3' from 'pygimli.core.core' (/home/runner/miniconda3/envs/test/lib/python3.11/site-packages/pygimli/core/core.py)
Traceback (most recent call last):
  File "/home/runner/miniconda3/envs/test/lib/python3.11/site-packages/pygimli/core/core.py", line 11, in <module>
    from . import _pygimli_  # if it works: as pgcore, replace all _pygimli_
    ^^^^^^^^^^^^^^^^^^^^^^^
ImportError: cannot import name '_pygimli_' from partially initialized module 'pygimli.core' (most likely due to a circular import) (/home/runner/miniconda3/envs/test/lib/python3.11/site-packages/pygimli/core/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/runner/miniconda3/envs/test/lib/python3.11/site-packages/pgcore/__init__.py", line 20, in <module>
    from ._pygimli_ import *
ImportError: libcholmod.so.3: cannot open shared object file: No such file or directory

You can find the last run here: https://github.com/emsig/emg3d/actions/runs/9740815664/job/26878698377

prisae commented 4 months ago

I just realize this might be related to #722

prisae commented 4 months ago

Interesting. Doing as suggested in #722, I installed pyGIMLi using pip. This worked. So there seems to be something broken with the conda-deploy of pyGIMLi?

prisae commented 4 months ago

I am closing this in favour of the older #722.