conda-forge / fenics-dolfinx-feedstock

A conda-smithy repository for fenics-dolfinx.
BSD 3-Clause "New" or "Revised" License
3 stars 5 forks source link

pkgconfig info missing? #31

Closed francesco-ballarin closed 1 year ago

francesco-ballarin commented 1 year ago

Hi, I am moving here the discussion from https://github.com/multiphenics/multiphenicsx/commit/b80f047c74827497ad6d1a689173d24e2e506974

It seems that conda packages do not ship pkgconfig info for dolfinx:

Python 3.11.0 | packaged by conda-forge | (main, Jan 14 2023, 12:27:40) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dolfinx.pkgconfig
>>> print(dolfinx.pkgconfig.exists("dolfinx"))
False
>>> print(dolfinx.pkgconfig.parse("dolfinx"))
{'define_macros': [], 'include_dirs': [], 'library_dirs': [], 'libraries': []}

When building from source, I get instead

Python 3.10.9 (main, Dec  7 2022, 13:47:07) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dolfinx.pkgconfig
>>> print(dolfinx.pkgconfig.exists("dolfinx"))
True
>>> print(dolfinx.pkgconfig.parse("dolfinx"))
{'define_macros': ['DOLFINX_VERSION=0.6.0.0', 'DOLFINX_VERSION=0.6.0.0', 'HAS_SLEPC', 'HAS_PTSCOTCH', 'HAS_PARMETIS', 'PKG_BASIX_DEFINITIONS-NOTFOUND'], 'include_dirs': ['/home/francesco/opt/personal/gnu/install/fenicsx/2023-02-10-bb7ac95c0f/petsc-2022-07-25-2c78e79264-3.17.3-real/include', '/home/francesco/opt/personal/gnu/install/slepc/2022-07-25-0ba3c7aea-3.17.1/petsc-2022-07-25-2c78e79264-3.17.3-real/include', '/usr/include/hdf5/openmpi', '/home/francesco/opt/personal/gnu/install/petsc/2022-07-25-2c78e79264-3.17.3/real/opt/include', '/home/francesco/opt/personal/gnu/install/fenicsx/2023-02-10-bb7ac95c0f/petsc-2022-07-25-2c78e79264-3.17.3-real/lib/python3.10/site-packages/ffcx/codegeneration'], 'library_dirs': ['/home/francesco/opt/personal/gnu/install/slepc/2022-07-25-0ba3c7aea-3.17.1/petsc-2022-07-25-2c78e79264-3.17.3-real/lib', '/home/francesco/opt/personal/gnu/install/petsc/2022-07-25-2c78e79264-3.17.3/real/opt/lib', '/home/francesco/opt/personal/gnu/install/fenicsx/2023-02-10-bb7ac95c0f/petsc-2022-07-25-2c78e79264-3.17.3-real/lib'], 'libraries': ['slepc', 'petsc', 'boost_timer', 'dolfinx']}

The file responsible for the compilation of the C++ backend in the multiphenicsx repo is https://github.com/multiphenics/multiphenicsx/blob/b80f047c74827497ad6d1a689173d24e2e506974/multiphenicsx/cpp/compile_code.py and I am actually surprised how multiphenicsx ever worked with dolfinx from conda, considering that without pkgconfig info multiphenicsx e.g. never links to petsc! (my gut feeling is that, since multiphenicsx imports dolfinx and dolfinx imports dolfinx.cpp, then petsc and all other shared libraries are getting loaded by dolfinx.cpp in the python process, and this somehow defines symbols to be used afterwards also for multiphenicsx.cpp)

Please ping @hermanmakhm if tests on the actual conda environment need to be run, since I don't have access to it.

francesco-ballarin commented 1 year ago

Hi @minrk, I bump this issue, since we just had the same report at https://github.com/multiphenics/multiphenicsx/discussions/12.

Thanks!

EvgeniyAzarov commented 1 year ago

Hi @francesco-ballarin and @minrk , I ran into the same problem, and figured out that it can be easily solved with just installing pkg-config in the conda environment. More precisely, in the environment with dolfinx run

conda install -c conda-forge pkg-config

Before the installation I had

$ pkg-config dolfinx --cflags
Package dolfinx was not found in the pkg-config search path.
Perhaps you should add the directory containing `dolfinx.pc'
to the PKG_CONFIG_PATH environment variable
No package 'dolfinx' found

After installation:

$ pkg-config dolfinx --cflags
-fvisibility-inlines-hidden -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/fenics-dolfinx-split_1676643338970/work=/usr/local/src/conda/fenics-libdolfinx-0.6.0 -fdebug-prefix-map=/home/user/mambaforge/envs/fenicsx-env=/usr/local/src/conda-prefix -DDOLFINX_VERSION=\"0.6.0\" -DDOLFINX_VERSION=0.6.0 -DHAS_ADIOS2 -DHAS_SLEPC -DHAS_PARMETIS -DPKG_BASIX_DEFINITIONS-NOTFOUND -isystem /home/user/mambaforge/envs/fenicsx-env/include -I/home/user/mambaforge/envs/fenicsx-env/include -IPKGCONFIG_DOLFINX_INCLUDE_DIRECTORIES-NOTFOUND

Hope it helps

minrk commented 1 year ago

Nice, sounds like pkg-config should be a dependency of the dolfinx package.

francesco-ballarin commented 1 year ago

Great, thanks @EvgeniyAzarov and @minrk