Skip to content

Commit ee07fc2

Browse files
authored
3.2.0 release prep (#127)
* tweak Development.Module support to not include Apple * force cmake > 3.11 for building with pip * bump CMAKE_CXX_STANDARD to c++17 to match PDAL * fetch drivers and options directly from the library instead of shelling out to 'pdal' command * bump version no to 3.2.0 * bypass DEVELOPMENT_COMPONENT for now * compare_structured_arrays method for testing array equality now that numpy 1.23.0's deprecation has taken effect * PDAL 2.4 uses / separators all the time * Implement #123, rename _get_json to toJSON * Revert "Implement #123, rename _get_json to toJSON" This reverts commit f35c3dd. * no more editable installs * Revert "Revert "Implement #123, rename _get_json to toJSON"" This reverts commit 085bce2. * fix #119, put back json alias to Pipeline * fix #125 and set 'type' for getJSON serialization * regularize access to a pipeline's srswkt2 to fix #112 * update CHANGES * changes note * updates and changes as suggested by review
1 parent f370cb1 commit ee07fc2

File tree

11 files changed

+88
-48
lines changed

11 files changed

+88
-48
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ jobs:
4444
python=${{ matrix.python-version }}
4545
4646
- name: Install python-pdal
47-
run: pip install -e .
47+
run: pip install .
4848

4949
- name: Install python-pdal-plugins
5050
working-directory: ./plugins
51-
run: pip install -e .
51+
run: pip install .
5252

5353
- name: Test
5454
run: |

CHANGES.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11
Changes
22
--------------------------------------------------------------------------------
33

4+
3.2.0
5+
................................................................................
6+
7+
* PDAL base library 2.4.0+ is required
8+
9+
* CMake project name updated to pdal-python
10+
11+
* `srswkt2` property added to allow fetching of SRS info
12+
13+
* pip builds require cmake >= 3.11
14+
15+
* CMAKE_CXX_STANDARD set to c++17 to match PDAL 2.4.x
16+
17+
* Driver and options *actually* uses the library instead of
18+
shelling out to `pdal` application :)
19+
20+
* _get_json renamed to toJSON and made public
21+
22+
* Fix #119, 'json' optional kwarg put back for now
23+
24+
* DEVELOPMENT_COMPONENT in CMake FindPython skipped on OSX
25+
26+
* Make sure 'type' gets set when serializing to JSON
27+
428
3.1.0
529
................................................................................
630

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.11.0)
22
project(pdal-python)
33

4-
set(CMAKE_CXX_STANDARD 11)
4+
set(CMAKE_CXX_STANDARD 17)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66
set(CMAKE_CXX_EXTENSIONS OFF)
77
set(CMAKE_BUILD_TYPE "Release")
@@ -13,14 +13,14 @@ set(Python3_FIND_FRAMEWORK "LAST")
1313

1414
# Development vs. Development.Module
1515
# https://cmake.org/cmake/help/latest/module/FindPython3.html?highlight=Development.Module
16-
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.18.0")
16+
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.18.0" AND NOT APPLE)
1717
set(DEVELOPMENT_COMPONENT "Development.Module")
1818
else()
1919
set(DEVELOPMENT_COMPONENT "Development")
2020
endif()
2121

2222
# find Python3
23-
find_package(Python3 COMPONENTS Interpreter "${DEVELOPMENT_COMPONENT}" NumPy REQUIRED)
23+
find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
2424

2525
# find PDAL. Require 2.1+
2626
find_package(PDAL 2.4 REQUIRED)

pdal/PyPipeline.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ point_count_t PipelineExecutor::execute()
8080
return count;
8181
}
8282

83+
std::string PipelineExecutor::getSrsWKT2() const
84+
{
85+
std::string output("");
86+
pdal::PointTableRef pointTable = m_manager.pointTable();
87+
88+
89+
pdal::SpatialReference srs = pointTable.spatialReference();
90+
output = srs.getWKT();
91+
92+
return output;
93+
}
8394

8495
point_count_t PipelineExecutor::executeStream(point_count_t streamLimit)
8596
{

pdal/PyPipeline.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class PDAL_DLL PipelineExecutor {
6161
std::string getMetadata() const;
6262
std::string getQuickInfo() const;
6363
std::string getSchema() const;
64+
std::string getSrsWKT2() const;
65+
PipelineManager const& getManager() const { return m_manager; }
6466
std::string getLog() const { return m_logStream.str(); }
6567

6668
protected:

pdal/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "3.1.2"
1+
__version__ = "3.2.0"
22
__all__ = ["Pipeline", "Stage", "Reader", "Filter", "Writer", "dimensions", "info"]
33

44
from . import libpdalpython

pdal/drivers.py

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -63,33 +63,9 @@ def factory(self) -> Callable[..., Stage]:
6363

6464
def inject_pdal_drivers() -> None:
6565

66-
# drivers = libpdalpython.getDrivers()
67-
#
68-
# options = libpdalpython.getOptions()
66+
drivers = libpdalpython.getDrivers()
67+
options = libpdalpython.getOptions()
6968

70-
drivers = json.loads(
71-
subprocess.run(["pdal", "--drivers", "--showjson"], capture_output=True).stdout
72-
)
73-
options = dict(
74-
json.loads(
75-
subprocess.run(
76-
["pdal", "--options", "all", "--showjson"], capture_output=True
77-
).stdout
78-
)
79-
)
80-
81-
command = 'pdal --options all --showjson'
82-
83-
p = subprocess.run(shlex.split(command),
84-
encoding='utf-8',
85-
capture_output=True)
86-
output, error = p.stdout, p.stderr
87-
if p.returncode:
88-
print (f'return code {p.returncode} error: "{error}"')
89-
if error:
90-
raise RuntimeError(f"Unable to run pdal --options with error '{error}'")
91-
92-
options = dict( json.loads( output ))
9369
streamable = []
9470
for d in drivers:
9571
name = d["name"]

pdal/libpdalpython.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,17 @@ namespace pdal {
5757

5858
};
5959

60-
std::vector<py::object> getOptions() {
60+
py::object getOptions() {
6161
py::gil_scoped_acquire acquire;
6262
py::object json = py::module_::import("json");
63-
std::vector<py::object> stageOptions;
63+
py::dict stageOptions;
6464

6565
pdal::StageFactory f;
6666
pdal::PluginManager<pdal::Stage>::loadAll();
6767
pdal::StringList stages = pdal::PluginManager<pdal::Stage>::names();
6868

6969
for (auto name : stages)
7070
{
71-
if ( name == "filters.info" ) continue;
7271
pdal::Stage *s = f.createStage(name);
7372
pdal::ProgramArgs args;
7473
s->addAllArgs(args);
@@ -82,13 +81,12 @@ namespace pdal {
8281
try {
8382
j = json.attr("loads")(pystring);
8483
} catch (py::error_already_set &e) {
85-
std::cout << "failed:" << name << "'" << ostr.str() << "'" <<std::endl;
84+
std::cerr << "failed:" << name << "'" << ostr.str() << "'" <<std::endl;
8685
continue; // skip this one because we can't parse it
8786
}
8887

8988
f.destroyStage(s);
90-
py::list l = py::make_tuple( name, pystring);
91-
stageOptions.push_back(std::move(l));
89+
stageOptions[pybind11::cast(name)] = std::move(j);
9290
}
9391
return stageOptions;
9492

@@ -178,6 +176,7 @@ namespace pdal {
178176
std::string getLog() { return getExecutor()->getLog(); }
179177

180178
std::string getPipeline() { return getExecutor()->getPipeline(); }
179+
std::string getSrsWKT2() { return getExecutor()->getSrsWKT2(); }
181180

182181
py::object getQuickInfo() {
183182
py::gil_scoped_acquire acquire;
@@ -220,7 +219,7 @@ namespace pdal {
220219
}
221220

222221
std::string getJson() const {
223-
PYBIND11_OVERRIDE_PURE_NAME(std::string, Pipeline, "_get_json", getJson);
222+
PYBIND11_OVERRIDE_PURE_NAME(std::string, Pipeline, "toJSON", getJson);
224223
}
225224

226225
bool hasInputs() { return !_inputs.empty(); }
@@ -248,6 +247,7 @@ namespace pdal {
248247
.def("__next__", &PipelineIterator::executeNext)
249248
.def_property_readonly("log", &PipelineIterator::getLog)
250249
.def_property_readonly("schema", &PipelineIterator::getSchema)
250+
.def_property_readonly("srswkt2", &PipelineIterator::getSrsWKT2)
251251
.def_property_readonly("pipeline", &PipelineIterator::getPipeline)
252252
.def_property_readonly("metadata", &PipelineIterator::getMetadata);
253253

@@ -260,14 +260,15 @@ namespace pdal {
260260
.def_property("loglevel", &Pipeline::getLoglevel, &Pipeline::setLogLevel)
261261
.def_property_readonly("log", &Pipeline::getLog)
262262
.def_property_readonly("schema", &Pipeline::getSchema)
263+
.def_property_readonly("srswkt2", &Pipeline::getSrsWKT2)
263264
.def_property_readonly("pipeline", &Pipeline::getPipeline)
264265
.def_property_readonly("quickinfo", &Pipeline::getQuickInfo)
265266
.def_property_readonly("metadata", &Pipeline::getMetadata)
266267
.def_property_readonly("arrays", &Pipeline::getArrays)
267268
.def_property_readonly("meshes", &Pipeline::getMeshes)
268269
.def_property_readonly("_has_inputs", &Pipeline::hasInputs)
269270
.def("_copy_inputs", &Pipeline::copyInputs)
270-
.def("_get_json", &Pipeline::getJson)
271+
.def("toJSON", &Pipeline::getJson)
271272
.def("_del_executor", &Pipeline::delExecutor);
272273
m.def("getInfo", &getInfo);
273274
m.def("getDrivers", &getDrivers);

pdal/pipeline.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ def __init__(
2828
spec: Union[None, str, Sequence[Stage]] = None,
2929
arrays: Sequence[np.ndarray] = (),
3030
loglevel: int = logging.ERROR,
31+
json: Optional[str] = None
3132
):
33+
if json:
34+
if spec and json:
35+
raise ValueError("provide 'spec' or 'json' arguments, not both")
36+
spec = json
37+
3238
super().__init__()
3339
self._stages: List[Stage] = []
3440
if spec:
@@ -107,6 +113,9 @@ def get_meshio(self, idx: int) -> Optional[Mesh]:
107113
)
108114

109115
def _get_json(self) -> str:
116+
return self.toJSON()
117+
118+
def toJSON(self) -> str:
110119
options_list = []
111120
stage2tag: Dict[Stage, str] = {}
112121
stages = self._stages
@@ -121,6 +130,7 @@ def _get_json(self) -> str:
121130
if inputs:
122131
options["inputs"] = inputs
123132
options_list.append(options)
133+
124134
return json.dumps(options_list)
125135

126136

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[build-system]
2-
requires = ["scikit-build", "cmake", "ninja", "numpy", "pybind11[global]"]
2+
requires = ["scikit-build", "cmake>=3.11", "ninja", "numpy", "pybind11[global]"]

0 commit comments

Comments
 (0)