Deltares / UGridPy

A Python wrapper for the UGrid library.
MIT License
7 stars 2 forks source link

Request: Add Linux support #6

Open priscavdsluis opened 2 years ago

priscavdsluis commented 2 years ago

Context In hydrolib, we are working on adding Binder support to improve our documentation and to make it easy and accessible for users to play around with hydrolib in their web browser without the need to make a local install of the hydrolib environments. Binder uses Docker to run environments, and Docker only creates Linux containers.

Problem When using UGridPy in a Docker container (after an install from a requirements.txt) the following error occurs: OSError: /srv/conda/envs/notebook/lib/python3.10/site-packages/ugrid/UGridApi.so: cannot open shared object file: No such file or directory

Is it possible to add support this? Or is there a work around that you know of in the mean time?

arthurvd commented 1 year ago

@priscavdsluis: our hydrolib Binder/Docker users are now also facing this issue, so I am upvoting this enhancement request :-) The obvious error that they're getting is:

---> 47     with UGrid(
     48         input_file_path,
     49         "r",
     50     ) as ug:
     52         data = ug.variable_get_data_double(variable)
     54     return data

File /srv/conda/envs/notebook/lib/python3.10/site-packages/ugrid/ugrid.py:57, in UGrid.__init__(self, file_path, method)
     54 else:
     55     raise OSError(f"Unsupported operating system: {system}")
---> 57 self.lib = CDLL(str(lib_path))
     58 self.__open(file_path, method)

File /srv/conda/envs/notebook/lib/python3.10/ctypes/__init__.py:374, in CDLL.__init__(self, name, mode, handle, use_errno, use_last_error, winmode)
    371 self._FuncPtr = _FuncPtr
    373 if handle is None:
--> 374     self._handle = _dlopen(self._name, mode)
    375 else:
    376     self._handle = handle

OSError: /srv/conda/envs/notebook/lib/python3.10/site-packages/ugrid/UGridApi.so: cannot open shared object file: No such file or directory

@lucacarniato will reach out to @evetion or @Hofer-Julian to ask for their help with making the pip-installable versions of both MeshKernelPy and UGridPy to support Linux.

There is already some investigation going on for MeshKernel, see draft PR: https://github.com/Deltares/MeshKernel/pull/114