From ec0a82d2e19db2fa9b3ee5ce362a03fe68be35e6 Mon Sep 17 00:00:00 2001 From: dancergraham Date: Tue, 12 Mar 2024 21:29:28 +0100 Subject: [PATCH] build: Upgrade libE57Format to v 3.1.1 --- pyproject.toml | 1 - src/pye57/__version__.py | 2 +- src/pye57/libe57_wrapper.cpp | 64 +++++++++++++++++++++++++----------- tests/test_main.py | 16 +++++++++ 4 files changed, 61 insertions(+), 22 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4160815..1014a4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,5 +15,4 @@ build-backend = "setuptools.build_meta" # before-all = "powershell scripts/install_xerces_c.ps1" test-requires = "pytest" build = "cp*-manylinux_x86_64 cp*-win_amd64*" -skip = "cp36*" test-command = "python -m pytest {project}/tests" diff --git a/src/pye57/__version__.py b/src/pye57/__version__.py index f6b7e26..cd1ee63 100644 --- a/src/pye57/__version__.py +++ b/src/pye57/__version__.py @@ -1 +1 @@ -__version__ = "0.4.3" +__version__ = "0.4.4" diff --git a/src/pye57/libe57_wrapper.cpp b/src/pye57/libe57_wrapper.cpp index f15b5f8..3672311 100644 --- a/src/pye57/libe57_wrapper.cpp +++ b/src/pye57/libe57_wrapper.cpp @@ -55,6 +55,27 @@ PYBIND11_MODULE(libe57, m) { m.attr("CHECKSUM_POLICY_SPARSE") = CHECKSUM_POLICY_SPARSE; m.attr("CHECKSUM_POLICY_HALF") = CHECKSUM_POLICY_HALF; m.attr("CHECKSUM_POLICY_ALL") = CHECKSUM_POLICY_ALL; + m.attr("E57_INT8_MIN") = INT8_MIN; + // for some reason INT8_MAX casts to a string not to an int ! + m.attr("E57_INT8_MAX") = 127; + m.attr("E57_INT16_MIN") = INT16_MIN; + m.attr("E57_INT16_MAX") = INT16_MAX; + m.attr("E57_INT32_MIN") = INT32_MIN; + m.attr("E57_INT32_MAX") = INT32_MAX; + m.attr("E57_INT64_MIN") = INT64_MIN; + m.attr("E57_INT64_MAX") = INT64_MAX; + m.attr("E57_UINT8_MIN") = UINT8_MIN; + m.attr("E57_UINT8_MAX") = UINT8_MAX; + m.attr("E57_UINT16_MIN") = UINT16_MIN; + m.attr("E57_UINT16_MAX") = UINT16_MAX; + m.attr("E57_UINT32_MIN") = UINT32_MIN; + m.attr("E57_UINT32_MAX") = UINT32_MAX; + m.attr("E57_UINT64_MIN") = UINT64_MIN; + m.attr("E57_UINT64_MAX") = UINT64_MAX; + m.attr("E57_FLOAT_MIN") = FLOAT_MIN; + m.attr("E57_FLOAT_MAX") = FLOAT_MAX; + m.attr("E57_DOUBLE_MIN") = DOUBLE_MIN; + m.attr("E57_DOUBLE_MAX") = DOUBLE_MAX; py::enum_(m, "NodeType") .value("E57_STRUCTURE", NodeType::E57_STRUCTURE) .value("E57_VECTOR", NodeType::E57_VECTOR) @@ -467,26 +488,29 @@ PYBIND11_MODULE(libe57, m) { return arr; }); - py::class_ cls_ImageFile(m, "ImageFile"); - cls_ImageFile.def(py::init(), "fname"_a, "mode"_a, "checksumPolicy"_a=CHECKSUM_POLICY_ALL); - cls_ImageFile.def("root", &ImageFile::root); - cls_ImageFile.def("close", &ImageFile::close); - cls_ImageFile.def("cancel", &ImageFile::cancel); - cls_ImageFile.def("isOpen", &ImageFile::isOpen); - cls_ImageFile.def("isWritable", &ImageFile::isWritable); - cls_ImageFile.def("fileName", &ImageFile::fileName); - cls_ImageFile.def("writerCount", &ImageFile::writerCount); - cls_ImageFile.def("readerCount", &ImageFile::readerCount); - cls_ImageFile.def("extensionsAdd", &ImageFile::extensionsAdd, "prefix"_a, "uri"_a); -// cls_ImageFile.def("extensionsLookupPrefix", &ImageFile::extensionsLookupPrefix, "prefix"_a, "uri"_a); - cls_ImageFile.def("extensionsLookupUri", &ImageFile::extensionsLookupUri, "uri"_a, "prefix"_a); - cls_ImageFile.def("extensionsCount", &ImageFile::extensionsCount); - cls_ImageFile.def("extensionsPrefix", &ImageFile::extensionsPrefix, "index"_a); - cls_ImageFile.def("extensionsUri", &ImageFile::extensionsUri, "index"_a); - cls_ImageFile.def("isElementNameExtended", &ImageFile::isElementNameExtended, "elementName"_a); - cls_ImageFile.def("elementNameParse", &ImageFile::elementNameParse, "elementName"_a, "prefix"_a, "localPart"_a); - cls_ImageFile.def("checkInvariant", &ImageFile::checkInvariant, "doRecurse"_a=true); - cls_ImageFile.def("__repr__", [](const ImageFile &im) { + py::class_ (m, "ImageFile") + .def(py::init(), "fname"_a, "mode"_a, "checksumPolicy"_a=CHECKSUM_POLICY_ALL) + .def("root", &ImageFile::root) + .def("close", &ImageFile::close) + .def("cancel", &ImageFile::cancel) + .def("isOpen", &ImageFile::isOpen) + .def("isWritable", &ImageFile::isWritable) + .def("fileName", &ImageFile::fileName) + .def("writerCount", &ImageFile::writerCount) + .def("readerCount", &ImageFile::readerCount) + .def("extensionsAdd", &ImageFile::extensionsAdd, "prefix"_a, "uri"_a) +// I couldn't wrap the overloaded function so I call it directly + .def("extensionsLookupPrefix", [](const ImageFile &im, std::string &prefix, std::string &uri) { + return im.extensionsLookupPrefix(prefix, uri); + }, "prefix"_a, "uri"_a) + .def("extensionsLookupUri", &ImageFile::extensionsLookupUri, "uri"_a, "prefix"_a) + .def("extensionsCount", &ImageFile::extensionsCount) + .def("extensionsPrefix", &ImageFile::extensionsPrefix, "index"_a) + .def("extensionsUri", &ImageFile::extensionsUri, "index"_a) + .def("isElementNameExtended", &ImageFile::isElementNameExtended, "elementName"_a) + .def("elementNameParse", &ImageFile::elementNameParse, "elementName"_a, "prefix"_a, "localPart"_a) + .def("checkInvariant", &ImageFile::checkInvariant, "doRecurse"_a=true) + .def("__repr__", [](const ImageFile &im) { return ""; }); diff --git a/tests/test_main.py b/tests/test_main.py index a2804a8..c7d5366 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -61,6 +61,22 @@ def test_constants(): assert libe57.CHECKSUM_POLICY_SPARSE == 25 assert libe57.CHECKSUM_POLICY_HALF == 50 assert libe57.CHECKSUM_POLICY_ALL == 100 + assert libe57.E57_INT8_MIN == -128 + assert libe57.E57_INT8_MAX == 127 + assert libe57.E57_INT16_MIN == -32768 + assert libe57.E57_INT16_MAX == 32767 + assert libe57.E57_INT32_MIN == -2147483647 - 1 + assert libe57.E57_INT32_MAX == 2147483647 + assert libe57.E57_INT64_MIN == -9223372036854775807 - 1 + assert libe57.E57_INT64_MAX == 9223372036854775807 + assert libe57.E57_UINT8_MIN == 0 + assert libe57.E57_UINT8_MAX == 255 + assert libe57.E57_UINT16_MIN == 0 + assert libe57.E57_UINT16_MAX == 65535 + assert libe57.E57_UINT32_MIN == 0 + assert libe57.E57_UINT32_MAX == 4294967295 + assert libe57.E57_UINT64_MIN == 0 + assert libe57.E57_UINT64_MAX == 18446744073709551615 def test_open_imagefile(e57_path):