Skip to content

Allow using "filters.python" in a python process on OS X #76

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

Merged
merged 1 commit into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ macro(PDAL_PYTHON_ADD_TEST _name)
# endif()
endmacro(PDAL_PYTHON_ADD_TEST)

if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# For newer versions of python (3.8+), C extensions don't link against
# libpython and instead get symbol definitions from the python interpreter
# executable. PDAL plugins need to link against libpython, but if a plugin
# is loaded inside a python process, it must resolve symbols from the python
# executable instead of libpython. Using flat namespace allows that.
set(PYTHON_LINK_LIBRARY ${PYTHON_LINK_LIBRARY} -Wl,-flat_namespace)
endif()

PDAL_PYTHON_ADD_PLUGIN(numpy_reader reader numpy
FILES
Expand Down
26 changes: 26 additions & 0 deletions test/test_pypy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import unittest
import json
import pdal
import numpy
import os

DATADIRECTORY = "./test/data"


def a_filter(ins, outs):
return True


class TestPythonInPython(unittest.TestCase):
def test_pipeline_construction(self):

pipeline = [
os.path.join(DATADIRECTORY, "autzen-utm.las"),
{
"type": "filters.python",
"script": __file__,
"function": "a_filter",
"module": "anything",
},
]
pdal.Pipeline(json.dumps(pipeline)).execute()