Skip to content

Commit c54644e

Browse files
committed
1 parent fcd9f32 commit c54644e

File tree

200 files changed

+93847
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+93847
-0
lines changed

.github/workflows/build.yml

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- '*'
7+
push:
8+
branches:
9+
- '*'
10+
release:
11+
types:
12+
- published
13+
jobs:
14+
unix:
15+
name: ${{ matrix.os }} - ${{ matrix.python-version }}
16+
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: true
20+
matrix:
21+
os: ['ubuntu-latest', 'macos-latest' ]
22+
python-version: ['3.7','3.8', '3.9']
23+
24+
steps:
25+
- uses: actions/checkout@v2
26+
- uses: conda-incubator/setup-miniconda@v2
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
mamba-version: "*"
30+
activate-environment: test
31+
channels: conda-forge
32+
auto-activate-base: false
33+
34+
- name: Linux dependencies
35+
if: matrix.os == 'ubuntu-latest'
36+
shell: bash -l {0}
37+
run: sudo apt-get install gcc-multilib -y
38+
39+
- name: Dependencies
40+
shell: bash -l {0}
41+
run: mamba install --yes --quiet -c conda-forge scikit-build numpy python=${{ matrix.python-version }} pdal
42+
43+
- name: Install
44+
shell: bash -l {0}
45+
run: |
46+
SKBUILD_CONFIGURE_OPTIONS="-DWITH_TESTS=ON" pip install -e .
47+
pdal --drivers
48+
49+
- name: Test
50+
shell: bash -l {0}
51+
run: |
52+
export PDAL_DRIVER_PATH=$(python -c "import skbuild; print(skbuild.constants.SKBUILD_DIR())")/cmake-build
53+
$PDAL_DRIVER_PATH/pdal_filters_python_test
54+
$PDAL_DRIVER_PATH/pdal_io_numpy_test
55+
56+
windows:
57+
name: ${{ matrix.os }} - ${{ matrix.python-version }}
58+
59+
runs-on: ${{ matrix.os }}
60+
strategy:
61+
fail-fast: true
62+
matrix:
63+
os: ['windows-latest']
64+
python-version: ['3.7','3.8', '3.9']
65+
66+
steps:
67+
- uses: actions/checkout@v2
68+
- uses: conda-incubator/setup-miniconda@v2
69+
with:
70+
channels: conda-forge
71+
python-version: ${{ matrix.python-version }}
72+
73+
- name: Dependencies
74+
shell: cmd /C CALL "{0}"
75+
run: |
76+
call conda activate test
77+
conda install --yes --quiet -c conda-forge scikit-build numpy python=${{ matrix.python-version }} pdal
78+
79+
- name: Install
80+
shell: cmd /C CALL "{0}"
81+
run: |
82+
call conda activate test
83+
set "SKBUILD_CONFIGURE_OPTIONS=-DWITH_TESTS=ON"
84+
pip install -e .
85+
pdal --drivers
86+
87+
- name: Test
88+
shell: cmd /C CALL "{0}"
89+
run: |
90+
call conda activate test
91+
set PYTHONHOME=%CONDA_PREFIX%
92+
for /f %%i in ('python -c "import skbuild; print(skbuild.constants.SKBUILD_DIR())"') do set PDAL_DRIVER_PATH=%%i\cmake-build
93+
%PDAL_DRIVER_PATH%\pdal_filters_python_test.exe
94+
%PDAL_DRIVER_PATH%\pdal_io_numpy_test.exe
95+
96+
dist:
97+
name: Distribution
98+
needs: [windows, unix]
99+
100+
runs-on: ${{ matrix.os }}
101+
strategy:
102+
fail-fast: true
103+
matrix:
104+
os: ['ubuntu-latest']
105+
python-version: ['3.8']
106+
107+
steps:
108+
- uses: actions/checkout@v2
109+
- uses: conda-incubator/setup-miniconda@v2
110+
with:
111+
channels: conda-forge
112+
python-version: ${{ matrix.python-version }}
113+
mamba-version: "*"
114+
115+
- name: Dependencies
116+
shell: bash -l {0}
117+
run: mamba install --yes --quiet -c conda-forge scikit-build numpy python=${{ matrix.python-version }} pdal
118+
119+
- name: sdist
120+
shell: bash -l {0}
121+
run: |
122+
python setup.py sdist
123+
ls dist
124+
125+
- uses: pypa/gh-action-pypi-publish@master
126+
name: Publish package
127+
if: github.event_name == 'release' && github.event.action == 'published'
128+
with:
129+
user: __token__
130+
password: ${{ secrets.pypi_token }}
131+
packages_dir: ./dist

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.vscode/
2+
_skbuild/
3+
MANIFEST
4+
dist/
5+
*.egg-info/
6+
*.o
7+
*.so
8+
*.dylib
9+
.DS_Store

CMakeLists.txt

+245
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
cmake_minimum_required(VERSION 3.11.0)
2+
project(PDAL)
3+
4+
set(CMAKE_CXX_STANDARD 11)
5+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6+
set(CMAKE_CXX_EXTENSIONS OFF)
7+
option(WITH_TESTS "Enable tests" OFF)
8+
set(CMAKE_BUILD_TYPE "Release")
9+
10+
# Python-finding settings
11+
set(Python3_FIND_STRATEGY "LOCATION")
12+
set(Python3_FIND_REGISTRY "LAST")
13+
set(Python3_FIND_FRAMEWORK "LAST")
14+
find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
15+
16+
# find PDAL. Require 2.1+
17+
find_package(PDAL 2.1 REQUIRED)
18+
19+
# Taken and adapted from PDAL's cmake macros.cmake
20+
21+
function(pdal_python_target_compile_settings target)
22+
set_property(TARGET ${target} PROPERTY CXX_STANDARD 11)
23+
set_property(TARGET ${target} PROPERTY CXX_STANDARD_REQUIRED TRUE)
24+
target_compile_definitions(${target} PRIVATE
25+
-DWIN32_LEAN_AND_MEAN)
26+
if (MSVC)
27+
# check for MSVC 8+
28+
if (NOT (MSVC_VERSION VERSION_LESS 1400))
29+
target_compile_definitions(${target} PRIVATE
30+
-D_CRT_SECURE_NO_DEPRECATE
31+
-D_CRT_SECURE_NO_WARNINGS
32+
-D_CRT_NONSTDC_NO_WARNING
33+
-D_SCL_SECURE_NO_WARNINGS
34+
)
35+
target_compile_options(${target} PRIVATE
36+
# Yes, we don't understand GCC pragmas
37+
/wd4068
38+
# Nitro makes use of Exception Specifications, which results in
39+
# numerous warnings when compiling in MSVC. We will ignore
40+
# them for now.
41+
/wd4290
42+
/wd4800
43+
# Windows warns about integer narrowing like crazy and it's
44+
# annoying. In most cases the programmer knows what they're
45+
# doing. A good static analysis tool would be better than
46+
# turning this warning off.
47+
/wd4267
48+
# Annoying warning about function hiding with virtual
49+
# inheritance.
50+
/wd4250
51+
# some templates don't return
52+
# /wd4716
53+
# unwind semantics
54+
# /wd4530
55+
# Standard C++-type exception handling.
56+
/EHsc
57+
)
58+
endif()
59+
60+
endif()
61+
endfunction()
62+
63+
64+
###############################################################################
65+
# Add a plugin target.
66+
# _name The plugin name.
67+
# ARGN :
68+
# FILES the source files for the plugin
69+
# LINK_WITH link plugin with libraries
70+
# INCLUDES header directories
71+
#
72+
# The "generate_dimension_hpp" ensures that Dimension.hpp is built before
73+
# attempting to build anything else in the "library".
74+
#
75+
# NOTE: _name is the name of a variable that will hold the plugin name
76+
# when the macro completes
77+
macro(PDAL_PYTHON_ADD_PLUGIN _name _type _shortname)
78+
set(options)
79+
set(oneValueArgs)
80+
set(multiValueArgs FILES LINK_WITH INCLUDES SYSTEM_INCLUDES COMPILE_OPTIONS)
81+
cmake_parse_arguments(PDAL_PYTHON_ADD_PLUGIN "${options}" "${oneValueArgs}"
82+
"${multiValueArgs}" ${ARGN})
83+
if(WIN32)
84+
set(WINSOCK_LIBRARY ws2_32)
85+
set(${_name} "libpdal_plugin_${_type}_${_shortname}")
86+
else()
87+
set(${_name} "pdal_plugin_${_type}_${_shortname}")
88+
endif()
89+
90+
91+
add_library(${${_name}} SHARED ${PDAL_PYTHON_ADD_PLUGIN_FILES})
92+
pdal_python_target_compile_settings(${${_name}})
93+
target_include_directories(${${_name}} PRIVATE
94+
${PROJECT_BINARY_DIR}/include
95+
${PDAL_INCLUDE_DIR}
96+
${PDAL_PYTHON_ADD_PLUGIN_INCLUDES}
97+
)
98+
target_link_options(${${_name}} BEFORE PRIVATE ${PDAL_PYTHON_ADD_PLUGIN_COMPILE_OPTIONS})
99+
target_compile_definitions(${${_name}} PRIVATE
100+
PDAL_PYTHON_LIBRARY="${PYTHON_LIBRARY}" PDAL_DLL_EXPORT)
101+
target_compile_definitions(${${_name}} PRIVATE PDAL_DLL_EXPORT)
102+
if (PDAL_PYTHON_ADD_PLUGIN_SYSTEM_INCLUDES)
103+
target_include_directories(${${_name}} SYSTEM PRIVATE
104+
${PDAL_PYTHON_ADD_PLUGIN_SYSTEM_INCLUDES})
105+
endif()
106+
target_link_libraries(${${_name}} PRIVATE
107+
${PDAL_PYTHON_ADD_PLUGIN_LINK_WITH}
108+
${WINSOCK_LIBRARY}
109+
)
110+
111+
message(STATUS "PROJECT_NAME: ${PROJECT_NAME}")
112+
install(TARGETS ${${_name}} LIBRARY DESTINATION "pdal")
113+
if (APPLE)
114+
set_target_properties(${${_name}} PROPERTIES
115+
INSTALL_NAME_DIR "@rpath")
116+
endif()
117+
endmacro(PDAL_PYTHON_ADD_PLUGIN)
118+
119+
120+
macro(PDAL_PYTHON_ADD_TEST _name)
121+
set(options)
122+
set(oneValueArgs)
123+
set(multiValueArgs FILES LINK_WITH INCLUDES SYSTEM_INCLUDES)
124+
cmake_parse_arguments(PDAL_PYTHON_ADD_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
125+
if (WIN32)
126+
set(WINSOCK_LIBRARY ws2_32)
127+
endif()
128+
add_executable(${_name} ${PDAL_PYTHON_ADD_TEST_FILES})
129+
130+
pdal_python_target_compile_settings(${_name})
131+
target_include_directories(${_name} PRIVATE
132+
${PDAL_PYTHON_ADD_TEST_INCLUDES})
133+
if (PDAL_PYTHON_ADD_TEST_SYSTEM_INCLUDES)
134+
target_include_directories(${_name} SYSTEM PRIVATE
135+
${PDAL_PYTHON_ADD_TEST_SYSTEM_INCLUDES})
136+
endif()
137+
set_property(TARGET ${_name} PROPERTY FOLDER "Tests")
138+
target_link_libraries(${_name}
139+
PRIVATE
140+
${PDAL_PYTHON_ADD_TEST_LINK_WITH}
141+
gtest
142+
${WINSOCK_LIBRARY}
143+
)
144+
target_compile_definitions(${_name} PRIVATE
145+
PDAL_PYTHON_LIBRARY="${PYTHON_LIBRARY}")
146+
add_test(NAME ${_name}
147+
COMMAND
148+
"${PROJECT_BINARY_DIR}/bin/${_name}"
149+
WORKING_DIRECTORY
150+
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/..")
151+
endmacro(PDAL_PYTHON_ADD_TEST)
152+
153+
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
154+
# For newer versions of python (3.8+), C extensions don't link against
155+
# libpython and instead get symbol definitions from the python interpreter
156+
# executable. PDAL plugins need to link against libpython, but if a plugin
157+
# is loaded inside a python process, it must resolve symbols from the python
158+
# executable instead of libpython. Using flat namespace allows that.
159+
set(PYTHON_LINK_LIBRARY ${PYTHON_LINK_LIBRARY} -Wl,-flat_namespace)
160+
endif()
161+
162+
PDAL_PYTHON_ADD_PLUGIN(numpy_reader reader numpy
163+
FILES
164+
./pdal/io/NumpyReader.cpp
165+
./pdal/io/NumpyReader.hpp
166+
./pdal/plang/Invocation.cpp
167+
./pdal/plang/Environment.cpp
168+
./pdal/plang/Redirector.cpp
169+
./pdal/plang/Script.cpp
170+
LINK_WITH
171+
${PDAL_LIBRARIES}
172+
${Python3_LIBRARIES}
173+
${CMAKE_DL_LIBS}
174+
SYSTEM_INCLUDES
175+
${PDAL_INCLUDE_DIRS}
176+
${Python3_INCLUDE_DIRS}
177+
${Python3_NumPy_INCLUDE_DIRS}
178+
COMPILE_OPTIONS
179+
${PYTHON_LINK_LIBRARY}
180+
)
181+
182+
PDAL_PYTHON_ADD_PLUGIN(python_filter filter python
183+
FILES
184+
./pdal/filters/PythonFilter.cpp
185+
./pdal/filters/PythonFilter.hpp
186+
./pdal/plang/Invocation.cpp
187+
./pdal/plang/Environment.cpp
188+
./pdal/plang/Redirector.cpp
189+
./pdal/plang/Script.cpp
190+
LINK_WITH
191+
${PDAL_LIBRARIES}
192+
${Python3_LIBRARIES}
193+
${CMAKE_DL_LIBS}
194+
SYSTEM_INCLUDES
195+
${PDAL_INCLUDE_DIRS}
196+
${Python3_INCLUDE_DIRS}
197+
${Python3_NumPy_INCLUDE_DIRS}
198+
COMPILE_OPTIONS
199+
${PYTHON_LINK_LIBRARY}
200+
)
201+
202+
203+
if (WITH_TESTS)
204+
enable_testing()
205+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
206+
add_subdirectory(pdal/test/gtest)
207+
enable_testing()
208+
include_directories(pdal/test/gtest/include .. ${CMAKE_CURRENT_BINARY_DIR})
209+
PDAL_PYTHON_ADD_TEST(pdal_io_numpy_test
210+
FILES
211+
./pdal/test/NumpyReaderTest.cpp
212+
./pdal/test/Support.cpp
213+
./pdal/plang/Invocation.cpp
214+
./pdal/plang/Environment.cpp
215+
./pdal/plang/Redirector.cpp
216+
./pdal/plang/Script.cpp
217+
LINK_WITH
218+
${numpy_reader}
219+
${Python3_LIBRARIES}
220+
${PDAL_LIBRARIES}
221+
${CMAKE_DL_LIBS}
222+
SYSTEM_INCLUDES
223+
${PDAL_INCLUDE_DIRS}
224+
${Python3_INCLUDE_DIRS}
225+
${Python3_NumPy_INCLUDE_DIRS}
226+
)
227+
PDAL_PYTHON_ADD_TEST(pdal_filters_python_test
228+
FILES
229+
./pdal/test/PythonFilterTest.cpp
230+
./pdal/test/Support.cpp
231+
./pdal/plang/Invocation.cpp
232+
./pdal/plang/Environment.cpp
233+
./pdal/plang/Redirector.cpp
234+
./pdal/plang/Script.cpp
235+
LINK_WITH
236+
${python_filter}
237+
${Python3_LIBRARIES}
238+
${PDAL_LIBRARIES}
239+
${CMAKE_DL_LIBS}
240+
SYSTEM_INCLUDES
241+
${PDAL_INCLUDE_DIRS}
242+
${Python3_INCLUDE_DIRS}
243+
${Python3_NumPy_INCLUDE_DIRS}
244+
)
245+
endif (WITH_TESTS)

0 commit comments

Comments
 (0)