Description
Starting in Python 3.8 (https://docs.python.org/3/whatsnew/3.8.html) C extensions to python shouldn't link against libpython:
"On Unix, C extensions are no longer linked to libpython except on Android and Cygwin"
libpdal_plugin_filter_python.dylib does link against libpython however, and this is fine when invoking pipelines containing "filters.python" from the command line, but it breaks when pipelines are constructed/run by a python script (i.e. via import pdal
). In this case libpython is loaded within a python process, and various errors ensue. For me on OSX with Python3.9, it results in a double-free of the _heapq
module definition object.
A workaround is to not link python_filter against libpython, and instead pass -undefined dynamic_lookup
to the linker. This works for launching pipelines via python
, but breaks running pdal pipeline foo.json
on the command line. A hacky fix for the latter would be to call dlopen("libpython.dylib")
before loading python_filter if the code is not running in a python process.