Skip to content

pdal.Pipeline + filters.python is broken on Python >= 3.8 #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
froody opened this issue Dec 7, 2020 · 4 comments · Fixed by #76
Closed

pdal.Pipeline + filters.python is broken on Python >= 3.8 #75

froody opened this issue Dec 7, 2020 · 4 comments · Fixed by #76

Comments

@froody
Copy link
Contributor

froody commented Dec 7, 2020

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.

@abellgithub
Copy link
Collaborator

We've been aware of this since the Python people broke stuff. I don't think we're going to fix it. I'm sure there's a ticket somewhere with a long history, but I can't find it at the moment.

@hobu
Copy link
Member

hobu commented Dec 7, 2020

I have made some attempts to handle this on OSX, but it's a giant mess of permutations I wasn't able to cleanly figure out. Someone who is motivated to fix this could start there.

As @abellgithub stated, we are tired of trying to fix this. Given that that fix only needs to live in the PDAL Python codebase and PDAL proper, we can issue a new release if someone does provide a fix that does the right thing.

As for the permutations:

  • Different behaviors for different Python versions
  • Different behaviors for static vs dynamically linked Python
  • Different behaviors for CMake detection mechanism
  • Different behaviors for OSX, Linux, and Windows (and cygwin windows vs msvc windows)

@froody
Copy link
Contributor Author

froody commented Dec 8, 2020

@hobu @abellgithub I came up with an elegant fix, can you review it? Also I think darwin tests are broken on master.

@hobu
Copy link
Member

hobu commented Dec 8, 2020

I think you are going to need to condition this fix based on the Python version. Also, I believe Conda's Python can be built differently on OSX. Do you happen to know which Python build you are using?

@hobu hobu closed this as completed in #76 Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants