conda-forge / gmsh-feedstock

A conda-smithy repository for gmsh.
BSD 3-Clause "New" or "Revised" License
4 stars 13 forks source link

gmsh-4.11.dll not found #70

Open claudiushaag opened 1 year ago

claudiushaag commented 1 year ago

Solution to issue cannot be found in the documentation.

Issue

Hello!

First of all: thank you for providing gmsh for conda environments!

I'm trying to use gmsh to generate a large number of meshes from python code. It would be very handy to be able to import the python-api via a conda package, so other people of my research group can get started very fast. But by using the package, I ran into a problem, which I would like to explain here.

To make sure, the problem does not lie within the gmsh code itself: Connecting and using the gmsh python-api via downloading the sdk and making it findable in the conda-environment via 'conda develop' works flawlessly.

Reproducing the Error:

Analysis

Going through the lines (29-51, attached below) before the error in gmsh.py, one notices that the script is trying to find the "gmsh-4.11.dll" file in various destinations, but is not able to. This leads to libpath being None. Searching in the entire environment folder, I am only able to find "gmsh.dll" in "Library/bin". It seems to me, as "gmsh-4.11.dll" is not placed where it should be for the python api to work.

Looking at recipe/bld_gmsh.bat, I noticed the moving of "gmsh.dll" into the mentioned "Library/bin" folder. But I'm curious, why it would be missing the version number? With missing version number, it can only be found via gmsh.py if it is put into a folder searched by find_library(). Did gmsh maybe change the name of the .dll file with including the version number, so it cannot be found anymore?

I would really appreciate your help solving this. I tried to have a look into the problem as deep as I could, as I do not have any experience in providing conda-packages. I hope I was able to explain the problem.

Code Example:

The problematic code is basically this snippet in gmsh.py.

moduledir = os.path.dirname(os.path.realpath(__file__))
if platform.system() == "Windows":
    libname = "gmsh-4.11.dll"
    libdir = os.path.dirname(moduledir)
elif platform.system() == "Darwin":
    libname = "libgmsh.4.11.dylib"
    libdir = os.path.dirname(os.path.dirname(moduledir))
else:
    libname = "libgmsh.so.4.11"
    libdir = os.path.dirname(os.path.dirname(moduledir))

libpath = os.path.join(libdir, libname)
if not os.path.exists(libpath):
    libpath = os.path.join(libdir, "Lib", libname)
if not os.path.exists(libpath):
    libpath = os.path.join(moduledir, libname)
if not os.path.exists(libpath):
    if platform.system() == "Windows":
        libpath = find_library("gmsh-4.11")
        if not libpath:
            libpath = find_library("gmsh")
    else:
        libpath = find_library("gmsh")

lib = CDLL(libpath)

Installed packages

aiohttp                   3.8.4           py311ha68e1ae_0    conda-forge
aiosignal                 1.3.1              pyhd8ed1ab_0    conda-forge
aom                       3.5.0                h63175ca_0    conda-forge
async-timeout             4.0.2              pyhd8ed1ab_0    conda-forge
attrs                     22.2.0             pyh71513ae_0    conda-forge
bzip2                     1.0.8                h8ffe710_4    conda-forge
ca-certificates           2022.12.7            h5b45459_0    conda-forge
charset-normalizer        2.1.1              pyhd8ed1ab_0    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
curl                      7.88.0               h68f0423_0    conda-forge
double-conversion         3.2.0                h63175ca_1    conda-forge
eigen                     3.4.0                h2d74725_0    conda-forge
expat                     2.5.0                h1537add_0    conda-forge
ffmpeg                    5.1.2           gpl_h5b1d025_106    conda-forge
fltk                      1.3.8                hb0cff51_0    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 hab24e00_0    conda-forge
fontconfig                2.14.2               hbde0cde_0    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
freeimage                 3.18.0              h30d40d2_12    conda-forge
freetype                  2.12.1               h546665d_1    conda-forge
frozenlist                1.3.3           py311ha68e1ae_0    conda-forge
gettext                   0.21.1               h5728263_0    conda-forge
gl2ps                     1.4.2                h0597ee9_0    conda-forge
glew                      2.1.0                h39d44d4_2    conda-forge
glib                      2.74.1               h12be248_1    conda-forge
glib-tools                2.74.1               h12be248_1    conda-forge
gmsh                      4.11.0               h03e301d_1    conda-forge
gst-plugins-base          1.22.0               h001b923_0    conda-forge
gstreamer                 1.22.0               h6b5321d_0    conda-forge
hdf4                      4.2.15               h1b1b6ef_5    conda-forge
hdf5                      1.12.2          nompi_h57737ce_101    conda-forge
icu                       70.1                 h0e60522_0    conda-forge
idna                      3.4                pyhd8ed1ab_0    conda-forge
imath                     3.1.6                h12be248_1    conda-forge
intel-openmp              2023.0.0         h57928b3_25922    conda-forge
jpeg                      9e                   hcfcfb64_3    conda-forge
jsoncpp                   1.9.5                h2d74725_1    conda-forge
jxrlib                    1.1                  h8ffe710_2    conda-forge
krb5                      1.20.1               heb0366b_0    conda-forge
lcms2                     2.14                 ha5c8aab_1    conda-forge
lerc                      4.0.0                h63175ca_0    conda-forge
libaec                    1.0.6                h63175ca_1    conda-forge
libblas                   3.9.0              16_win64_mkl    conda-forge
libcblas                  3.9.0              16_win64_mkl    conda-forge
libclang                  15.0.7          default_h77d9078_1    conda-forge
libclang13                15.0.7          default_h77d9078_1    conda-forge
libcurl                   7.88.0               h68f0423_0    conda-forge
libdeflate                1.17                 hcfcfb64_0    conda-forge
libffi                    3.4.2                h8ffe710_5    conda-forge
libglib                   2.74.1               he8f3873_1    conda-forge
libhwloc                  2.8.0                h039e092_1    conda-forge
libiconv                  1.17                 h8ffe710_0    conda-forge
liblapack                 3.9.0              16_win64_mkl    conda-forge
libnetcdf                 4.9.1           nompi_hc41bf00_100    conda-forge
libogg                    1.3.4                h8ffe710_1    conda-forge
libopus                   1.3.1                h8ffe710_1    conda-forge
libpng                    1.6.39               h19919ed_0    conda-forge
libraw                    0.21.1               h3eb7d9d_0    conda-forge
libsqlite                 3.40.0               hcfcfb64_0    conda-forge
libssh2                   1.10.0               h9a1e1f7_3    conda-forge
libtheora                 1.1.1             h8d14728_1005    conda-forge
libtiff                   4.5.0                hf8721a0_2    conda-forge
libvorbis                 1.3.7                h0e60522_0    conda-forge
libwebp-base              1.2.4                h8ffe710_0    conda-forge
libxcb                    1.13              hcd874cb_1004    conda-forge
libxml2                   2.10.3               hc3477c8_0    conda-forge
libzip                    1.9.2                h519de47_1    conda-forge
libzlib                   1.2.13               hcfcfb64_4    conda-forge
loguru                    0.6.0           py311h1ea47a8_2    conda-forge
lz4-c                     1.9.4                hcfcfb64_0    conda-forge
m2w64-gcc-libgfortran     5.3.0                         6    conda-forge
m2w64-gcc-libs            5.3.0                         7    conda-forge
m2w64-gcc-libs-core       5.3.0                         7    conda-forge
m2w64-gmp                 6.1.0                         2    conda-forge
m2w64-libwinpthread-git   5.0.0.4634.697f757               2    conda-forge
mkl                       2022.1.0           h6a75c08_874    conda-forge
msys2-conda-epoch         20160418                      1    conda-forge
multidict                 6.0.4           py311ha68e1ae_0    conda-forge
nlohmann_json             3.11.2               h39d44d4_0    conda-forge
numpy                     1.24.2          py311h0b4df5a_0    conda-forge
occt                      7.7.0                h54f5ab0_2    conda-forge
openexr                   3.1.5                hab3b255_1    conda-forge
openh264                  2.3.1                h63175ca_2    conda-forge
openjpeg                  2.5.0                ha2aaf27_2    conda-forge
openssl                   3.0.8                hcfcfb64_0    conda-forge
pcre2                     10.40                h17e33f8_0    conda-forge
pip                       23.0               pyhd8ed1ab_0    conda-forge
proj                      9.1.1                heca977f_2    conda-forge
pthread-stubs             0.4               hcd874cb_1001    conda-forge
pthreads-win32            2.9.1                hfa6e2cd_3    conda-forge
pugixml                   1.11.4               h0e60522_0    conda-forge
python                    3.11.0          hcf16a7b_0_cpython    conda-forge
python-gmsh               4.11.0               h57928b3_1    conda-forge
python_abi                3.11                    3_cp311    conda-forge
qt-main                   5.15.8               h720456b_6    conda-forge
rapidjson                 1.1.0             ha925a31_1002    conda-forge
setuptools                67.3.1             pyhd8ed1ab_0    conda-forge
sqlite                    3.40.0               hcfcfb64_0    conda-forge
svt-av1                   1.4.1                h63175ca_0    conda-forge
tbb                       2021.7.0             h91493d7_1    conda-forge
tbb-devel                 2021.7.0             h91493d7_1    conda-forge
tk                        8.6.12               h8ffe710_0    conda-forge
typing-extensions         4.4.0                hd8ed1ab_0    conda-forge
typing_extensions         4.4.0              pyha770c72_0    conda-forge
tzdata                    2022g                h191b570_0    conda-forge
ucrt                      10.0.22621.0         h57928b3_0    conda-forge
utfcpp                    3.2.3                h57928b3_0    conda-forge
vc                        14.3                hb6edc58_10    conda-forge
vs2015_runtime            14.34.31931         h4c5c07a_10    conda-forge
vtk                       9.2.5           qt_py311hd10cacf_203    conda-forge
wheel                     0.38.4             pyhd8ed1ab_0    conda-forge
win32_setctime            1.1.0              pyhd8ed1ab_0    conda-forge
wslink                    1.10.1             pyhd8ed1ab_0    conda-forge
x264                      1!164.3095           h8ffe710_2    conda-forge
x265                      3.5                  h2d74725_3    conda-forge
xorg-fixesproto           5.0               hcd874cb_1002    conda-forge
xorg-kbproto              1.0.7             hcd874cb_1002    conda-forge
xorg-libice               1.0.10               hcd874cb_0    conda-forge
xorg-libsm                1.2.3             hcd874cb_1000    conda-forge
xorg-libx11               1.7.2                hcd874cb_0    conda-forge
xorg-libxau               1.0.9                hcd874cb_0    conda-forge
xorg-libxdmcp             1.1.3                hcd874cb_0    conda-forge
xorg-libxext              1.3.4                hcd874cb_1    conda-forge
xorg-libxfixes            5.0.3             hcd874cb_1004    conda-forge
xorg-libxrender           0.9.10            hcd874cb_1003    conda-forge
xorg-renderproto          0.11.1            hcd874cb_1002    conda-forge
xorg-xextproto            7.3.0             hcd874cb_1002    conda-forge
xorg-xproto               7.0.31            hcd874cb_1007    conda-forge
xz                        5.2.6                h8d14728_0    conda-forge
yarl                      1.8.2           py311ha68e1ae_0    conda-forge
zlib                      1.2.13               hcfcfb64_4    conda-forge
zstd                      1.5.2                h12be248_6    conda-forge

Environment info

active environment : gmsh_test
    active env location : C:\Users\XXXXX\Anaconda3\envs\gmsh_test
            shell level : 2
       user config file : C:\Users\XXXXX\.condarc
 populated config files : C:\Users\XXXXX\.condarc
          conda version : 23.1.0
    conda-build version : 3.23.3
         python version : 3.9.16.final.0
       virtual packages : __archspec=1=x86_64
                          __win=0=0
       base environment : C:\Users\XXXXX\Anaconda3  (writable)
      conda av data dir : C:\Users\XXXXX\Anaconda3\etc\conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Users\XXXXX\Anaconda3\pkgs
                          C:\Users\XXXXX\.conda\pkgs
                          C:\Users\XXXXX\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\XXXXX\Anaconda3\envs
                          C:\Users\XXXXXX\.conda\envs
                          C:\Users\XXXXX\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/23.1.0 requests/2.28.1 CPython/3.9.16 Windows/10 Windows/10.0.22621
          administrator : False
             netrc file : None
           offline mode : False
claudiushaag commented 1 year ago

After some more tries, the situation is now somewhat resolved. I don't know why, but find_library() is now able to find env/bin/gmsh.dll and loads it. It wasn't able to do so when creating this issue.

One point still stands: the gmsh.dll is not put something where it is originally expected by the GMSH projekt and the gmsh.py file. It is only found because of a fallback via scanning all directories related to the PATH-variables. In light of the errors I encountered, this would be a fix to make the package possibly more stable.

Sadly, I do not know how to do that.