geopython / pywps

PyWPS is an implementation of the Web Processing Service standard from the Open Geospatial Consortium. PyWPS is written in Python.
https://pywps.org
MIT License
178 stars 117 forks source link

Cannot load libgrass_gis.8.3.so #671

Open HuidaeCho opened 1 year ago

HuidaeCho commented 1 year ago

Description

I'm not sure where to report this issue. It might be a bug in the core GRASS (ctypes_loader.py?), but it only happens with PyWPS.

gisbase in the config file has no effect and the grass_gis.8.3 library cannot be loaded (it was actually found, but its first dependency libgrass_datetime.8.3.so was not found even though it's in the same directory).

$ uwsgi --socket :8080 --wsgi-file wps.py 
*** Starting uWSGI 2.0.20 (64bit) on [Fri Feb 10 02:48:34 2023] ***
compiled with version: 11.2.0 on 14 March 2022 10:14:17
os: Linux-5.15.80 #1 SMP PREEMPT Sun Nov 27 13:28:05 CST 2022
nodename: me.x
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 8
current working directory: /www/txmod
detected binary path: /usr/local/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 192676
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address :8080 fd 3
Python version: 3.9.16 (main, Dec  7 2022, 11:34:25)  [GCC 11.2.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x727c20
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 72920 bytes (71 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x727c20 pid: 20350 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 20350, cores: 1)
[pid: 20350|app: 0|req: 1/1] 174.56.8.172 () {66 vars in 1068 bytes} [Fri Feb 10 02:48:40 2023] POST /wps/ => generated 975 bytes in 133 msecs (HTTP/1.1 200) 2 headers in 79 bytes (1 switches on core 0)
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pywps/app/Process.py", line 243, in _run_process
    self._set_grass(wps_request)
  File "/usr/local/lib/python3.9/site-packages/pywps/app/Process.py", line 421, in _set_grass
    from grass.pygrass.gis import make_mapset
  File "/usr/grass/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/pygrass/gis/__init__.py", line 19, in <module>
    import grass.lib.gis as libgis
  File "/usr/grass/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/lib/gis.py", line 30, in <module>
    _libs["grass_gis.8.3"] = load_library("grass_gis.8.3")
  File "/usr/grass/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/lib/ctypes_loader.py", line 105, in __call__
    raise ImportError("Could not load %s." % libname)
ImportError: Could not load grass_gis.8.3.

Setting LD_LIBRARY_PATH outside the pywps script works fine.

I tried:

Environment

Steps to Reproduce

wps.py

#!/usr/bin/env python3
from pywps.app import Service
from grasstmod import GrassTmod

application = Service([GrassTmod()], ["/www/txmod/wps.cfg"])

wps.cfg

...
[grass]
gisbase=/usr/grass/grass/dist.x86_64-pc-linux-gnu/

Additional Information

Workaround

LD_LIBRARY_PATH=/usr/grass/grass/dist.x86_64-pc-linux-gnu/lib uwsgi --socket :8080 --wsgi-file wps.py