Skip to content

PetscPythonFindLibrary: One more way to get pythonlib.

Vaclav Hapla requested to merge haplav/fix-petscpythonfindlibrary into release

Fix for case when Python sysconfig.get_config_var("LDLIBRARY") yields libpython<version>.a erroneously while there is actually libpython<version>.so present in the filesystem.

The problem I had (with Conda python 3.9.1 hffdb5ce_3_cpython conda-forge)

> $PETSC_DIR/src/ksp/ksp/tutorials/ex100
[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
[0]PETSC ERROR: Python: failed to load symbols from Python dynamic library 
...
[0]PETSC ERROR: #1 PetscPythonLoadLibrary() line 147 in /mnt/md0/Drive/Users/vhapla/petsc-3/src/sys/python/pythonsys.c
[0]PETSC ERROR: #2 PetscPythonInitialize() line 206 in /mnt/md0/Drive/Users/vhapla/petsc-3/src/sys/python/pythonsys.c
[0]PETSC ERROR: #3 main() line 89 in ex100.c

This was caused by PetscPythonFindLibrary() not finding the shared library as sysconfig.get_config_var("LDLIBRARY") returned libpython3.9.a which didn't even exist in the filesystem. This seems to be a known issue.

Merge request reports