RBniCSx installation error

Good evening,

I cannot install RBniCSx.

After I run

git clone https://github.com/RBniCS/RBniCSx
cd RBniCSx
python3 -m pip install .

I get the following error:

Processing /mnt/c/RBniCSx
  Installing build dependencies ... error
  error: subprocess-exited-with-error

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [88 lines of output]
      Collecting nanobind>=1.8.0
        Using cached nanobind-1.9.2-py3-none-any.whl.metadata (1.4 kB)
      Collecting petsc4py
        Using cached petsc4py-3.21.0.tar.gz (415 kB)
        Preparing metadata (setup.py): started
        Preparing metadata (setup.py): finished with status 'done'
      Collecting scikit-build-core[pyproject]
        Using cached scikit_build_core-0.8.2-py3-none-any.whl.metadata (19 kB)
      Collecting numpy (from petsc4py)
        Using cached numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)
      Collecting petsc<3.22,>=3.21 (from petsc4py)
        Using cached petsc-3.21.0.tar.gz (17.3 MB)
        Preparing metadata (setup.py): started
        Preparing metadata (setup.py): finished with status 'done'
      Collecting packaging>=20.9 (from scikit-build-core[pyproject])
        Using cached packaging-24.0-py3-none-any.whl.metadata (3.2 kB)
      Collecting pathspec>=0.10.1 (from scikit-build-core[pyproject])
        Using cached pathspec-0.12.1-py3-none-any.whl.metadata (21 kB)
      Collecting pyproject-metadata>=0.5 (from scikit-build-core[pyproject])
        Using cached pyproject_metadata-0.7.1-py3-none-any.whl.metadata (3.0 kB)
      Using cached nanobind-1.9.2-py3-none-any.whl (192 kB)
      Using cached packaging-24.0-py3-none-any.whl (53 kB)
      Using cached pathspec-0.12.1-py3-none-any.whl (31 kB)
      Using cached pyproject_metadata-0.7.1-py3-none-any.whl (7.4 kB)
      Using cached numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.0 MB)
      Using cached scikit_build_core-0.8.2-py3-none-any.whl (140 kB)
      Building wheels for collected packages: petsc4py, petsc
        Building wheel for petsc4py (setup.py): started
        Building wheel for petsc4py (setup.py): finished with status 'error'
        error: subprocess-exited-with-error

        × python setup.py bdist_wheel did not run successfully.
        │ exit code: 1
        ╰─> [34 lines of output]
            running bdist_wheel
            PETSC_DIR not specified
            running build
            running build_src
            fetching build requirement 'Cython >= 3.0.0'
            using Cython 3.0.10
            cythonizing 'petsc4py/PETSc.pyx' -> 'petsc4py/PETSc.c'
            running build_py
            creating build
            creating build/lib.linux-x86_64-cpython-312
            creating build/lib.linux-x86_64-cpython-312/petsc4py
            copying src/petsc4py/__main__.py -> build/lib.linux-x86_64-cpython-312/petsc4py
            copying src/petsc4py/typing.py -> build/lib.linux-x86_64-cpython-312/petsc4py
            copying src/petsc4py/PETSc.py -> build/lib.linux-x86_64-cpython-312/petsc4py
            copying src/petsc4py/__init__.py -> build/lib.linux-x86_64-cpython-312/petsc4py
            creating build/lib.linux-x86_64-cpython-312/petsc4py/lib
            copying src/petsc4py/lib/__init__.py -> build/lib.linux-x86_64-cpython-312/petsc4py/lib
            copying src/petsc4py/__main__.pyi -> build/lib.linux-x86_64-cpython-312/petsc4py
            copying src/petsc4py/__init__.pyi -> build/lib.linux-x86_64-cpython-312/petsc4py
            copying src/petsc4py/py.typed -> build/lib.linux-x86_64-cpython-312/petsc4py
            copying src/petsc4py/PETSc.pxd -> build/lib.linux-x86_64-cpython-312/petsc4py
            copying src/petsc4py/PETSc.h -> build/lib.linux-x86_64-cpython-312/petsc4py
            copying src/petsc4py/PETSc_api.h -> build/lib.linux-x86_64-cpython-312/petsc4py
            creating build/lib.linux-x86_64-cpython-312/petsc4py/include
            creating build/lib.linux-x86_64-cpython-312/petsc4py/include/petsc4py
            copying src/petsc4py/include/petsc4py/numpy.h -> build/lib.linux-x86_64-cpython-312/petsc4py/include/petsc4py
            copying src/petsc4py/include/petsc4py/pyscalar.h -> build/lib.linux-x86_64-cpython-312/petsc4py/include/petsc4py
            copying src/petsc4py/include/petsc4py/pybuffer.h -> build/lib.linux-x86_64-cpython-312/petsc4py/include/petsc4py
            copying src/petsc4py/include/petsc4py/petsc4py.h -> build/lib.linux-x86_64-cpython-312/petsc4py/include/petsc4py
            copying src/petsc4py/include/petsc4py/petsc4py.i -> build/lib.linux-x86_64-cpython-312/petsc4py/include/petsc4py
            copying src/petsc4py/lib/__init__.pyi -> build/lib.linux-x86_64-cpython-312/petsc4py/lib
            copying src/petsc4py/lib/petsc.cfg -> build/lib.linux-x86_64-cpython-312/petsc4py/lib
            running build_ext
            error: PETSc not found
            [end of output]

        note: This error originates from a subprocess, and is likely not a problem with pip.
        ERROR: Failed building wheel for petsc4py
        Running setup.py clean for petsc4py
        Building wheel for petsc (setup.py): started
        Building wheel for petsc (setup.py): finished with status 'error'
        error: subprocess-exited-with-error

        × python setup.py bdist_wheel did not run successfully.
        │ exit code: 1
        ╰─> [1 lines of output]
            petsc: this package cannot be built as a wheel
            [end of output]

        note: This error originates from a subprocess, and is likely not a problem with pip.
        ERROR: Failed building wheel for petsc
        Running setup.py clean for petsc
      Failed to build petsc4py petsc
      ERROR: Could not build wheels for petsc4py, petsc, which is required to install pyproject.toml-based projects
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

I can see the problem is related to petsc and petsc4py.

When I run

pip install petsc4py

I get

Requirement already satisfied: petsc4py in /home/carlo/anaconda3/envs/fenicsx-env/lib/python3.12/site-packages (3.20.4)
Requirement already satisfied: numpy in /home/carlo/anaconda3/envs/fenicsx-env/lib/python3.12/site-packages (from petsc4py) (1.26.3)

However, when I try to run

pip install petsc

I get

Collecting petsc
  Using cached petsc-3.21.0.tar.gz (17.3 MB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: petsc
  Building wheel for petsc (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      petsc: this package cannot be built as a wheel
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for petsc
  Running setup.py clean for petsc
Failed to build petsc
ERROR: Could not build wheels for petsc, which is required to install pyproject.toml-based projects

Indeed I installed petsc through

conda install -c conda-forge petsc

And everything seems to work fine, indeed I get:

Channels:
 - conda-forge
 - defaults
Platform: linux-64
Collecting package metadata (repodata.json): done
Solving environment: done

# All requested packages already installed.

I cannot understand what is the problem related to petsc, and therefore with the installation of RBniCSx.

Thank you for your help.

Please follow the same installation instructions as multiphenicsx, see Installation — multiphenicsx

I should create a RBniCSx website with those installation instructions, but this is a busy period and doing so is not a high priority on my todo list.

It worked, thank you!