Skip to content

Commit

Permalink
build: Upgrade libE57Format to v 3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dancergraham committed Mar 12, 2024
1 parent cec5e79 commit ec0a82d
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 22 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion src/pye57/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.3"
__version__ = "0.4.4"
64 changes: 44 additions & 20 deletions src/pye57/libe57_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_<NodeType>(m, "NodeType")
.value("E57_STRUCTURE", NodeType::E57_STRUCTURE)
.value("E57_VECTOR", NodeType::E57_VECTOR)
Expand Down Expand Up @@ -467,26 +488,29 @@ PYBIND11_MODULE(libe57, m) {
return arr;
});

py::class_<ImageFile> cls_ImageFile(m, "ImageFile");
cls_ImageFile.def(py::init<const std::string &, const std::string &, int>(), "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_<ImageFile> (m, "ImageFile")
.def(py::init<const std::string &, const std::string &, int>(), "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 "<ImageFile '" + im.fileName() + "'>";
});

Expand Down
16 changes: 16 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ec0a82d

Please sign in to comment.