Skip to content

Commit 37ada19

Browse files
author
Tom Birch
committed
Allow using "filters.python" in a python process on OS X
1 parent 60ed38e commit 37ada19

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,14 @@ macro(PDAL_PYTHON_ADD_TEST _name)
223223
# endif()
224224
endmacro(PDAL_PYTHON_ADD_TEST)
225225

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

227235
PDAL_PYTHON_ADD_PLUGIN(numpy_reader reader numpy
228236
FILES

test/test_pypy.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import unittest
2+
import json
3+
import pdal
4+
import numpy
5+
import os
6+
7+
DATADIRECTORY = "./test/data"
8+
9+
10+
def test_filter(ins, outs):
11+
return True
12+
13+
14+
class TestPythonInPython(unittest.TestCase):
15+
def test_pipeline_construction(self):
16+
17+
pipeline = [
18+
os.path.join(DATADIRECTORY, "autzen-utm.las"),
19+
{
20+
"type": "filters.python",
21+
"script": __file__,
22+
"function": "test_filter",
23+
"module": "anything",
24+
},
25+
]
26+
pdal.Pipeline(json.dumps(pipeline)).execute()

0 commit comments

Comments
 (0)