From b462a78a05b07cf071cbf45664e75290fa70d4a4 Mon Sep 17 00:00:00 2001 From: henry Date: Wed, 18 Oct 2023 16:21:08 -0500 Subject: [PATCH] Update exiv2 dependency to v0.28.0 --- CMakeLists.txt | 2 +- MANIFEST.in | 4 +- cmake_scripts/external_exiv22.cmake | 16 ++++-- conanfile.py | 9 ++-- patches/tiff_resolution_path.patch | 38 ++++++------- pyproject.toml | 3 ++ setup.py | 53 +++++++++---------- .../py3exiv2bind}/__init__.py | 0 {py3exiv2bind => src/py3exiv2bind}/core.pyi | 0 .../py3exiv2bind}/core/CMakeLists.txt | 2 +- .../py3exiv2bind}/core/core.cpp | 2 +- .../py3exiv2bind}/core/core.h | 0 .../core/glue/AbsMetadataStrategy.h | 0 .../py3exiv2bind}/core/glue/CMakeLists.txt | 2 +- .../py3exiv2bind}/core/glue/ExifStrategy.cpp | 2 +- .../py3exiv2bind}/core/glue/ExifStrategy.h | 0 .../py3exiv2bind}/core/glue/IPTC_Strategy.cpp | 2 +- .../py3exiv2bind}/core/glue/IPTC_Strategy.h | 0 .../py3exiv2bind}/core/glue/Image.cpp | 9 ++-- .../py3exiv2bind}/core/glue/Image.h | 0 .../core/glue/MetadataProcessor.cpp | 0 .../core/glue/MetadataProcessor.h | 0 .../core/glue/MetadataStrategies.h | 0 .../py3exiv2bind}/core/glue/XmpStrategy.cpp | 2 +- .../py3exiv2bind}/core/glue/XmpStrategy.h | 0 .../py3exiv2bind}/core/glue/glue.cpp | 13 ++--- .../py3exiv2bind}/core/glue/glue.h | 2 - .../core/glue/glue_execeptions.h | 0 .../py3exiv2bind}/core/glue/make_dictionary.h | 0 {py3exiv2bind => src/py3exiv2bind}/icc.py | 0 {py3exiv2bind => src/py3exiv2bind}/image.py | 0 {py3exiv2bind => src/py3exiv2bind}/py.typed | 0 tests/CMakeLists.txt | 6 +-- tests/test_core.py | 10 ++-- tests/test_editing.cpp | 1 + tests/test_icc.py | 1 - tests/test_make_dictionary.cpp | 2 +- tox.ini | 4 +- 38 files changed, 91 insertions(+), 94 deletions(-) rename {py3exiv2bind => src/py3exiv2bind}/__init__.py (100%) rename {py3exiv2bind => src/py3exiv2bind}/core.pyi (100%) rename {py3exiv2bind => src/py3exiv2bind}/core/CMakeLists.txt (97%) rename {py3exiv2bind => src/py3exiv2bind}/core/core.cpp (96%) rename {py3exiv2bind => src/py3exiv2bind}/core/core.h (100%) rename {py3exiv2bind => src/py3exiv2bind}/core/glue/AbsMetadataStrategy.h (100%) rename {py3exiv2bind => src/py3exiv2bind}/core/glue/CMakeLists.txt (96%) rename {py3exiv2bind => src/py3exiv2bind}/core/glue/ExifStrategy.cpp (91%) rename {py3exiv2bind => src/py3exiv2bind}/core/glue/ExifStrategy.h (100%) rename {py3exiv2bind => src/py3exiv2bind}/core/glue/IPTC_Strategy.cpp (91%) rename {py3exiv2bind => src/py3exiv2bind}/core/glue/IPTC_Strategy.h (100%) rename {py3exiv2bind => src/py3exiv2bind}/core/glue/Image.cpp (94%) rename {py3exiv2bind => src/py3exiv2bind}/core/glue/Image.h (100%) rename {py3exiv2bind => src/py3exiv2bind}/core/glue/MetadataProcessor.cpp (100%) rename {py3exiv2bind => src/py3exiv2bind}/core/glue/MetadataProcessor.h (100%) rename {py3exiv2bind => src/py3exiv2bind}/core/glue/MetadataStrategies.h (100%) rename {py3exiv2bind => src/py3exiv2bind}/core/glue/XmpStrategy.cpp (90%) rename {py3exiv2bind => src/py3exiv2bind}/core/glue/XmpStrategy.h (100%) rename {py3exiv2bind => src/py3exiv2bind}/core/glue/glue.cpp (66%) rename {py3exiv2bind => src/py3exiv2bind}/core/glue/glue.h (84%) rename {py3exiv2bind => src/py3exiv2bind}/core/glue/glue_execeptions.h (100%) rename {py3exiv2bind => src/py3exiv2bind}/core/glue/make_dictionary.h (100%) rename {py3exiv2bind => src/py3exiv2bind}/icc.py (100%) rename {py3exiv2bind => src/py3exiv2bind}/image.py (100%) rename {py3exiv2bind => src/py3exiv2bind}/py.typed (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index f81b01b4..55c64f8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ if(pyexiv2bind_generate_python_bindings) add_subdirectory(${libpybind11_SOURCE_DIR} ${libpybind11_BINARY_DIR} EXCLUDE_FROM_ALL) endif () endif(pyexiv2bind_generate_python_bindings) -add_subdirectory(py3exiv2bind/core) +add_subdirectory(src/py3exiv2bind/core) set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${PROJECT_SOURCE_DIR}/_skbuild) include(CTest) add_subdirectory(tests) diff --git a/MANIFEST.in b/MANIFEST.in index ffaa9bec..979cb6d2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,7 @@ # Include the license file include tox.ini CHANGELOG.rst README.rst CMakeLists.txt tests/CMakeLists.txt requirements.txt requirements-dev.txt include conanfile.py -include py3exiv2bind/core.pyi +include src/py3exiv2bind/core.pyi include patches/*.patch include patches/*.cmake include pyproject.toml @@ -9,4 +9,4 @@ recursive-include cmake_scripts *.cmake recursive-include tests *.py *.cpp recursive-include docs/source *.* include docs/make.bat docs/Makefile -recursive-include py3exiv2bind *.py *.cpp *.h CMakeLists.txt +recursive-include src/py3exiv2bind *.py *.cpp *.h CMakeLists.txt diff --git a/cmake_scripts/external_exiv22.cmake b/cmake_scripts/external_exiv22.cmake index d7508ef1..d51345f0 100644 --- a/cmake_scripts/external_exiv22.cmake +++ b/cmake_scripts/external_exiv22.cmake @@ -21,9 +21,9 @@ function(patch_exiv2_cmake root) endfunction() function(patch_tiff_resolution root) - list(APPEND LINES_TO_BE_REMOVED "{ 0x011a, ifd0Id }, // Exif.Image.XResolution") - list(APPEND LINES_TO_BE_REMOVED "{ 0x011b, ifd0Id }, // Exif.Image.YResolution") - list(APPEND LINES_TO_BE_REMOVED "{ 0x0128, ifd0Id }, // Exif.Image.ResolutionUnit") + list(APPEND LINES_TO_BE_REMOVED "case 0x011a: // Exif.Image.XResolution") + list(APPEND LINES_TO_BE_REMOVED "case 0x011b: // Exif.Image.YResolution") + list(APPEND LINES_TO_BE_REMOVED "case 0x0128: // Exif.Image.ResolutionUnit") find_file( tiffimage_int @@ -37,14 +37,17 @@ function(patch_tiff_resolution root) file(READ "${tiffimage_int}" data) foreach(line ${LINES_TO_BE_REMOVED}) string(REPLACE "${line}" "" data "${data}") + message(STATUS "Removing line \"${line}\" from tiffimage_int.cpp") endforeach() file(WRITE "${libexiv2_BINARY_DIR}/tiffimage_int.cpp" "${data}") + message(STATUS "Modified the following source file to allow editing of Exif.Image.XResolution, Exif.Image.YResolution, and Exif.Image.ResolutionUnit: ${tiffimage_int}") execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${libexiv2_BINARY_DIR}/tiffimage_int.cpp" "${tiffimage_int}") endfunction() FetchContent_Declare( libexiv2 - URL https://github.com/Exiv2/exiv2/archive/refs/tags/v0.27.6.tar.gz + URL https://github.com/Exiv2/exiv2/archive/refs/tags/v0.28.0.tar.gz + URL_HASH SHA256=04c0675caf4338bb96cd09982f1246d588bcbfe8648c0f5a30b56c7c496f1a0b # GIT_REPOSITORY https://github.com/Exiv2/exiv2.git # GIT_TAG ${EXIV2_VERSION_TAG} # PATCH_COMMAND @@ -56,13 +59,16 @@ if (NOT libexiv2_POPULATED) FetchContent_Populate(libexiv2) patch_tiff_resolution("${libexiv2_SOURCE_DIR}") patch_exiv2_cmake("${libexiv2_SOURCE_DIR}") + option(EXIV2_ENABLE_INIH "" OFF) + option(EXIV2_BUILD_EXIV2_COMMAND "" OFF) + set(EXIV2_BUILD_EXIV2_COMMAND OFF CACHE BOOL "") set(EXIV2_BUILD_SAMPLES OFF CACHE BOOL "") option(EXIV2_BUILD_SAMPLES "" OFF) if(MSVC) option(EXIV2_ENABLE_DYNAMIC_RUNTIME "" ON) endif() + list(APPEND CMAKE_MODULE_PATH "${libexiv2_SOURCE_DIR}/cmake") include_directories(${libexiv2_BINARY_DIR}) add_subdirectory(${libexiv2_SOURCE_DIR} ${libexiv2_BINARY_DIR}) endif () - diff --git a/conanfile.py b/conanfile.py index d964ec87..7c053011 100644 --- a/conanfile.py +++ b/conanfile.py @@ -12,13 +12,10 @@ class pyexiv2bind(ConanFile): } def requirements(self): - # if self.settings.os == "Windows": - # self.requires("Expat/2.2.9@pix4d/stable") - # else: - self.requires("expat/2.4.2") + self.requires("brotli/1.0.9") + self.requires("expat/2.5.0") self.requires("zlib/1.2.11") - if self.settings.os == "Macos": - self.requires("libiconv/1.16") + self.requires("libiconv/1.17") def imports(self): self.copy("*.dll", dst="bin", src="bin") # From bin to bin self.copy("*.dylib*", dst=".", src="lib") # From lib to bin diff --git a/patches/tiff_resolution_path.patch b/patches/tiff_resolution_path.patch index e558bc97..33eba9b4 100644 --- a/patches/tiff_resolution_path.patch +++ b/patches/tiff_resolution_path.patch @@ -1,22 +1,22 @@ diff --git a/src/tiffimage_int.cpp b/src/tiffimage_int.cpp -index 7cd6656d..f31272ae 100644 +index e62c5228e..a9db0c673 100644 --- a/src/tiffimage_int.cpp +++ b/src/tiffimage_int.cpp -@@ -1828,14 +1828,14 @@ namespace Exiv2 { - { 0x0115, ifd0Id }, // Exif.Image.SamplesPerPixel - { 0x0116, ifd0Id }, // Exif.Image.RowsPerStrip - { 0x0117, ifd0Id }, // Exif.Image.StripByteCounts -- { 0x011a, ifd0Id }, // Exif.Image.XResolution -- { 0x011b, ifd0Id }, // Exif.Image.YResolution -+// { 0x011a, ifd0Id }, // Exif.Image.XResolution -+// { 0x011b, ifd0Id }, // Exif.Image.YResolution - { 0x011c, ifd0Id }, // Exif.Image.PlanarConfiguration - { 0x0122, ifd0Id }, // Exif.Image.GrayResponseUnit - { 0x0123, ifd0Id }, // Exif.Image.GrayResponseCurve - { 0x0124, ifd0Id }, // Exif.Image.T4Options - { 0x0125, ifd0Id }, // Exif.Image.T6Options -- { 0x0128, ifd0Id }, // Exif.Image.ResolutionUnit -+// { 0x0128, ifd0Id }, // Exif.Image.ResolutionUnit - { 0x0129, ifd0Id }, // Exif.Image.PageNumber - { 0x012d, ifd0Id }, // Exif.Image.TransferFunction - { 0x013d, ifd0Id }, // Exif.Image.Predictor +@@ -2237,14 +2237,14 @@ static bool isTiffImageTagLookup(uint16_t tag, IfdId group) { + case 0x0115: // Exif.Image.SamplesPerPixel + case 0x0116: // Exif.Image.RowsPerStrip + case 0x0117: // Exif.Image.StripByteCounts +- case 0x011a: // Exif.Image.XResolution +- case 0x011b: // Exif.Image.YResolution ++// case 0x011a: // Exif.Image.XResolution ++// case 0x011b: // Exif.Image.YResolution + case 0x011c: // Exif.Image.PlanarConfiguration + case 0x0122: // Exif.Image.GrayResponseUnit + case 0x0123: // Exif.Image.GrayResponseCurve + case 0x0124: // Exif.Image.T4Options + case 0x0125: // Exif.Image.T6Options +- case 0x0128: // Exif.Image.ResolutionUnit ++// case 0x0128: // Exif.Image.ResolutionUnit + case 0x0129: // Exif.Image.PageNumber + case 0x012d: // Exif.Image.TransferFunction + case 0x013d: // Exif.Image.Predictor diff --git a/pyproject.toml b/pyproject.toml index e1f08b00..3fe5c0fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,9 @@ requires = [ "conan>=1.50.0,<2.0" ] build-backend = "uiucprescon.build" +[tool.pytest.ini_options] +pythonpath = "src" +testpaths = ["tests"] [tool.cibuildwheel] test-requires = [ diff --git a/setup.py b/setup.py index db9db70e..b075256a 100644 --- a/setup.py +++ b/setup.py @@ -27,22 +27,22 @@ exiv2_extension = Pybind11Extension( "py3exiv2bind.core", sources=[ - "py3exiv2bind/core/core.cpp", - "py3exiv2bind/core/glue/ExifStrategy.cpp", - "py3exiv2bind/core/glue/glue.cpp", - "py3exiv2bind/core/glue/Image.cpp", - "py3exiv2bind/core/glue/IPTC_Strategy.cpp", - "py3exiv2bind/core/glue/XmpStrategy.cpp", - "py3exiv2bind/core/glue/MetadataProcessor.cpp", + "src/py3exiv2bind/core/core.cpp", + "src/py3exiv2bind/core/glue/ExifStrategy.cpp", + "src/py3exiv2bind/core/glue/glue.cpp", + "src/py3exiv2bind/core/glue/Image.cpp", + "src/py3exiv2bind/core/glue/IPTC_Strategy.cpp", + "src/py3exiv2bind/core/glue/XmpStrategy.cpp", + "src/py3exiv2bind/core/glue/MetadataProcessor.cpp", ], libraries=[ "exiv2", ], include_dirs=[ - "py3exiv2bind/core/glue", + "src/py3exiv2bind/core/glue", ], language='c++', - cxx_std=14 + cxx_std=17 ) extension_modules.append(exiv2_extension) @@ -80,7 +80,6 @@ def platform_specific_configs(self): sys_root = self.get_cmake_osx_sysroot() if sys_root is not None: configs.append(sys_root) - configs.append('-DEXIV2_BUILD_EXIV2_COMMAND:BOOL=ON') return configs @staticmethod @@ -289,7 +288,7 @@ def build_install_cmake(self, extension: Pybind11Extension): for ext in build_ext_cmd.extensions: ext.library_dirs.insert( 0, - os.path.abspath(os.path.join(build_ext_cmd.build_lib, "py3exiv2bind")) + os.path.abspath(os.path.join(build_ext_cmd.build_lib, "src/py3exiv2bind")) ) build_ext_cmd.include_dirs.insert( 0, @@ -411,24 +410,22 @@ def run(self): metadata_strategy = ConanBuildInfoTXT() text_md = metadata_strategy.parse(conanbuildinfotext) for lib in text_md["libs"]: - core_ext.libraries.append(lib) - for path in text_md["lib_paths"]: - core_ext.library_dirs.append(path) + if lib not in core_ext.libraries: + core_ext.libraries.append(lib) + for path in reversed(text_md["lib_paths"]): + core_ext.library_dirs.insert(0, path) - core_ext.include_dirs.append(os.path.join(self.build_temp, "include")) + core_ext.include_dirs.insert(0, os.path.join(self.build_temp, "include")) if os.name == 'nt': core_ext.libraries.append("shell32") core_ext.libraries.append("psapi") core_ext.libraries.append("Ws2_32") - core_ext.libraries.append("exiv2-xmp") - temp_lib_dir = os.path.join(self.build_temp, "lib") if temp_lib_dir not in core_ext.library_dirs: core_ext.library_dirs.insert(0, temp_lib_dir) - exiv2 = ("exiv2", { "sources": [], "CMAKE_SOURCE_DIR": os.path.dirname(__file__), @@ -436,7 +433,8 @@ def run(self): '-Dpyexiv2bind_generate_python_bindings:BOOL=NO', '-DEXIV2_ENABLE_NLS:BOOL=NO', '-DEXIV2_ENABLE_VIDEO:BOOL=OFF', - '-DEXIV2_ENABLE_PNG:BOOL=OFF' + '-DEXIV2_ENABLE_PNG:BOOL=OFF', + '-DEXIV2_BUILD_EXIV2_COMMAND:BOOL=OFF' ], }) @@ -446,19 +444,19 @@ def run(self): exiv2_extension = Pybind11Extension( "py3exiv2bind.core", sources=[ - "py3exiv2bind/core/core.cpp", - "py3exiv2bind/core/glue/ExifStrategy.cpp", - "py3exiv2bind/core/glue/glue.cpp", - "py3exiv2bind/core/glue/Image.cpp", - "py3exiv2bind/core/glue/IPTC_Strategy.cpp", - "py3exiv2bind/core/glue/XmpStrategy.cpp", - "py3exiv2bind/core/glue/MetadataProcessor.cpp", + "src/py3exiv2bind/core/core.cpp", + "src/py3exiv2bind/core/glue/ExifStrategy.cpp", + "src/py3exiv2bind/core/glue/glue.cpp", + "src/py3exiv2bind/core/glue/Image.cpp", + "src/py3exiv2bind/core/glue/IPTC_Strategy.cpp", + "src/py3exiv2bind/core/glue/XmpStrategy.cpp", + "src/py3exiv2bind/core/glue/MetadataProcessor.cpp", ], libraries=[ "exiv2", ], include_dirs=[ - "py3exiv2bind/core/glue" + "src/py3exiv2bind/core/glue" ], language='c++', @@ -479,5 +477,6 @@ def run(self): package_data={ "py3exiv2bind": ["py.typed", "core.pyi"], }, + package_dir={"py3exiv2bind": "src/py3exiv2bind"}, cmdclass=cmd_class ) diff --git a/py3exiv2bind/__init__.py b/src/py3exiv2bind/__init__.py similarity index 100% rename from py3exiv2bind/__init__.py rename to src/py3exiv2bind/__init__.py diff --git a/py3exiv2bind/core.pyi b/src/py3exiv2bind/core.pyi similarity index 100% rename from py3exiv2bind/core.pyi rename to src/py3exiv2bind/core.pyi diff --git a/py3exiv2bind/core/CMakeLists.txt b/src/py3exiv2bind/core/CMakeLists.txt similarity index 97% rename from py3exiv2bind/core/CMakeLists.txt rename to src/py3exiv2bind/core/CMakeLists.txt index 93646fa8..0f5b2b33 100644 --- a/py3exiv2bind/core/CMakeLists.txt +++ b/src/py3exiv2bind/core/CMakeLists.txt @@ -15,7 +15,7 @@ if (pyexiv2bind_generate_python_bindings) python_extension_module(core) endif() set_target_properties(core PROPERTIES - CXX_STANDARD 11 + CXX_STANDARD 17 LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/py3exiv2bind RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/py3exiv2bind PREFIX "${PYTHON_MODULE_PREFIX}" diff --git a/py3exiv2bind/core/core.cpp b/src/py3exiv2bind/core/core.cpp similarity index 96% rename from py3exiv2bind/core/core.cpp rename to src/py3exiv2bind/core/core.cpp index de497ee4..9623c8b9 100644 --- a/py3exiv2bind/core/core.cpp +++ b/src/py3exiv2bind/core/core.cpp @@ -37,7 +37,7 @@ PYBIND11_MODULE(core, m) { .def("is_good", &Image::is_good, "Check if a file is loaded.") ; pybind11::register_exception(m, "NoICCError"); - pybind11::register_exception(m, "Exiv2AnyError"); + pybind11::register_exception(m, "Exiv2Error"); m.def("set_dpi", &set_dpi, pybind11::arg("image"), pybind11::arg("x"), diff --git a/py3exiv2bind/core/core.h b/src/py3exiv2bind/core/core.h similarity index 100% rename from py3exiv2bind/core/core.h rename to src/py3exiv2bind/core/core.h diff --git a/py3exiv2bind/core/glue/AbsMetadataStrategy.h b/src/py3exiv2bind/core/glue/AbsMetadataStrategy.h similarity index 100% rename from py3exiv2bind/core/glue/AbsMetadataStrategy.h rename to src/py3exiv2bind/core/glue/AbsMetadataStrategy.h diff --git a/py3exiv2bind/core/glue/CMakeLists.txt b/src/py3exiv2bind/core/glue/CMakeLists.txt similarity index 96% rename from py3exiv2bind/core/glue/CMakeLists.txt rename to src/py3exiv2bind/core/glue/CMakeLists.txt index 0ad6ffbe..b3c1e820 100644 --- a/py3exiv2bind/core/glue/CMakeLists.txt +++ b/src/py3exiv2bind/core/glue/CMakeLists.txt @@ -21,6 +21,6 @@ target_include_directories(glue PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRE $ ) set_target_properties(glue PROPERTIES - CXX_STANDARD 14 + CXX_STANDARD 17 ) target_link_libraries(glue PRIVATE exiv2lib) \ No newline at end of file diff --git a/py3exiv2bind/core/glue/ExifStrategy.cpp b/src/py3exiv2bind/core/glue/ExifStrategy.cpp similarity index 91% rename from py3exiv2bind/core/glue/ExifStrategy.cpp rename to src/py3exiv2bind/core/glue/ExifStrategy.cpp index 4618691d..e5571be5 100644 --- a/py3exiv2bind/core/glue/ExifStrategy.cpp +++ b/src/py3exiv2bind/core/glue/ExifStrategy.cpp @@ -10,7 +10,7 @@ std::unordered_map ExifStrategy::load(const Exiv2::Image &image){ try{ return make_dictionary(image.exifData()); - }catch (const Exiv2::AnyError &e){ + }catch (const Exiv2::Error &e){ // TODO: Handle errors std::cerr << e.what() < IPTC_Strategy::load(const Exiv2::Image &image){ try{ return make_dictionary(image.iptcData()); - }catch (const Exiv2::AnyError &e){ + }catch (const Exiv2::Error &e){ // TODO: Handle errors std::cerr << e.what() <(Exiv2::ImageFactory::open(filename)); assert(image); // Make sure it's able to read the file image->readMetadata(); - } catch (const Exiv2::AnyError &e) { + } catch (const Exiv2::Error &e) { std::cerr << e.what() << std::endl; throw std::runtime_error(e.what()); } @@ -99,10 +99,11 @@ std::string Image::get_icc_profile() const { if (!image->iccProfileDefined()) { throw NoIccError(); } - const Exiv2::DataBuf *f = image->iccProfile(); - for(int i = 0; i < f->size_; i++){ - data << f->pData_[i]; + Exiv2::DataBuf buffer = image->iccProfile(); + for( auto const & byte: buffer){ + data << byte; } + data << std::endl; return data.str(); diff --git a/py3exiv2bind/core/glue/Image.h b/src/py3exiv2bind/core/glue/Image.h similarity index 100% rename from py3exiv2bind/core/glue/Image.h rename to src/py3exiv2bind/core/glue/Image.h diff --git a/py3exiv2bind/core/glue/MetadataProcessor.cpp b/src/py3exiv2bind/core/glue/MetadataProcessor.cpp similarity index 100% rename from py3exiv2bind/core/glue/MetadataProcessor.cpp rename to src/py3exiv2bind/core/glue/MetadataProcessor.cpp diff --git a/py3exiv2bind/core/glue/MetadataProcessor.h b/src/py3exiv2bind/core/glue/MetadataProcessor.h similarity index 100% rename from py3exiv2bind/core/glue/MetadataProcessor.h rename to src/py3exiv2bind/core/glue/MetadataProcessor.h diff --git a/py3exiv2bind/core/glue/MetadataStrategies.h b/src/py3exiv2bind/core/glue/MetadataStrategies.h similarity index 100% rename from py3exiv2bind/core/glue/MetadataStrategies.h rename to src/py3exiv2bind/core/glue/MetadataStrategies.h diff --git a/py3exiv2bind/core/glue/XmpStrategy.cpp b/src/py3exiv2bind/core/glue/XmpStrategy.cpp similarity index 90% rename from py3exiv2bind/core/glue/XmpStrategy.cpp rename to src/py3exiv2bind/core/glue/XmpStrategy.cpp index 9b89c20f..e0e07965 100644 --- a/py3exiv2bind/core/glue/XmpStrategy.cpp +++ b/src/py3exiv2bind/core/glue/XmpStrategy.cpp @@ -10,7 +10,7 @@ std::unordered_map XmpStrategy::load(const Exiv2::Imag try{ return make_dictionary(image.xmpData()); - }catch (const Exiv2::AnyError &e){ + }catch (const Exiv2::Error &e){ // TODO: Handle errors std::cerr << e.what() <exifData(); - metadata["Exif.Image.XResolution"] = create_DPI_string(x); - metadata["Exif.Image.YResolution"] = create_DPI_string(y); + metadata["Exif.Image.XResolution"] = Exiv2::URational(x, 1); + metadata["Exif.Image.YResolution"] = Exiv2::URational(y, 1); metadata["Exif.Image.ResolutionUnit"] = 2; image->setExifData(metadata); image->writeMetadata(); image->readMetadata(); - }catch (const Exiv2::AnyError &e) { + }catch (const Exiv2::Error &e) { throw; } } - -std::string create_DPI_string(int value){ - std::ostringstream response; - response << value; - response << "/1"; - return response.str(); -} diff --git a/py3exiv2bind/core/glue/glue.h b/src/py3exiv2bind/core/glue/glue.h similarity index 84% rename from py3exiv2bind/core/glue/glue.h rename to src/py3exiv2bind/core/glue/glue.h index 09c1b3ce..c6c82c77 100644 --- a/py3exiv2bind/core/glue/glue.h +++ b/src/py3exiv2bind/core/glue/glue.h @@ -7,7 +7,6 @@ #include #include -//#include "glue_export.h" struct metadata_chunk { @@ -22,5 +21,4 @@ std::string exiv2_version(); void set_dpi(const std::string &filename, int x, int y); -std::string create_DPI_string(int value); #endif //SUPERBUILD_GLUE_H diff --git a/py3exiv2bind/core/glue/glue_execeptions.h b/src/py3exiv2bind/core/glue/glue_execeptions.h similarity index 100% rename from py3exiv2bind/core/glue/glue_execeptions.h rename to src/py3exiv2bind/core/glue/glue_execeptions.h diff --git a/py3exiv2bind/core/glue/make_dictionary.h b/src/py3exiv2bind/core/glue/make_dictionary.h similarity index 100% rename from py3exiv2bind/core/glue/make_dictionary.h rename to src/py3exiv2bind/core/glue/make_dictionary.h diff --git a/py3exiv2bind/icc.py b/src/py3exiv2bind/icc.py similarity index 100% rename from py3exiv2bind/icc.py rename to src/py3exiv2bind/icc.py diff --git a/py3exiv2bind/image.py b/src/py3exiv2bind/image.py similarity index 100% rename from py3exiv2bind/image.py rename to src/py3exiv2bind/image.py diff --git a/py3exiv2bind/py.typed b/src/py3exiv2bind/py.typed similarity index 100% rename from py3exiv2bind/py.typed rename to src/py3exiv2bind/py.typed diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 63dad54b..d61a543f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -69,9 +69,9 @@ if (BUILD_TESTING) set_target_properties(cpp_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} RUNTIME_OUTPUT_NAME test - CXX_STANDARD 11 + CXX_STANDARD 17 ) - target_include_directories(cpp_tests PRIVATE ${PROJECT_SOURCE_DIR}/py3exiv2bind/core) + target_include_directories(cpp_tests PRIVATE ${PROJECT_SOURCE_DIR}/src/py3exiv2bind/core) target_link_libraries(cpp_tests PRIVATE Catch2::Catch2 exiv2lib) catch_discover_tests(cpp_tests TEST_PREFIX ${PROJECT_NAME}::test-pyexiv2::) @@ -83,7 +83,7 @@ if (BUILD_TESTING) set_target_properties(test_editing PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} - CXX_STANDARD 11 + CXX_STANDARD 17 ) target_link_libraries(test_editing PRIVATE exiv2lib Catch2::Catch2) target_compile_definitions(test_editing PRIVATE TEST_IMAGE_PATH="${TEST_IMAGE_PATH}") diff --git a/tests/test_core.py b/tests/test_core.py index db010c5f..81bb282c 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,7 +1,7 @@ # print("Running {}".format(__file__)) import os from py3exiv2bind import core - +print(core.exiv2_version()) def test_exiv_version(): exiv2_version = core.exiv2_version() @@ -24,15 +24,15 @@ def test_set_dpi_on_jp2(sample_images): def test_set_dpi_on_tiff(sample_images): - test_jp2 = os.path.join(sample_images, "dummy.tif") - sample_image = core.Image(test_jp2) + test_tiff = os.path.join(sample_images, "dummy.tif") + sample_image = core.Image(test_tiff) assert sample_image.exif['Exif.Image.XResolution'] != "400/1" assert sample_image.exif['Exif.Image.YResolution'] != "400/1" assert sample_image.exif['Exif.Image.ResolutionUnit'] == "2" # core.set_dpi(test_jp2, 300, 300) - core.set_dpi(image=str(test_jp2), x=300, y=300) - sample_image2 = core.Image(test_jp2) + core.set_dpi(image=str(test_tiff), x=300, y=300) + sample_image2 = core.Image(test_tiff) assert sample_image2.exif['Exif.Image.XResolution'] == "300/1" assert sample_image2.exif['Exif.Image.YResolution'] == "300/1" assert sample_image2.exif['Exif.Image.ResolutionUnit'] == "2" diff --git a/tests/test_editing.cpp b/tests/test_editing.cpp index 20ad2fb3..bec8b446 100644 --- a/tests/test_editing.cpp +++ b/tests/test_editing.cpp @@ -5,6 +5,7 @@ #include #include #include +#include void exifPrint(const Exiv2::ExifData& exifData); diff --git a/tests/test_icc.py b/tests/test_icc.py index ab15b213..adaa824f 100644 --- a/tests/test_icc.py +++ b/tests/test_icc.py @@ -1,5 +1,4 @@ import os -from pprint import pprint import pytest from py3exiv2bind import Image, core diff --git a/tests/test_make_dictionary.cpp b/tests/test_make_dictionary.cpp index 222cba19..b6aac97c 100644 --- a/tests/test_make_dictionary.cpp +++ b/tests/test_make_dictionary.cpp @@ -2,7 +2,7 @@ // Created by Borchers, Henry Samuel on 7/1/21. // #include -#include +#include #include #include diff --git a/tox.ini b/tox.ini index 96bbd0f6..dd65d849 100644 --- a/tox.ini +++ b/tox.ini @@ -9,9 +9,9 @@ passenv = deps = pytest pybind11 +install_command=python -I -m pip install {opts} {packages} -v --config-settings=conan_cache={env:CONAN_USER_HOME:{temp_dir}}{/}.conan +commands_pre=python -c "from py3exiv2bind import core;print(f'Testing against exiv2 version {core.exiv2_version()}')" commands = pytest {posargs} --basetemp={envtmpdir} -install_command=python -m pip install {opts} {packages} --config-settings=conan_cache={env:CONAN_USER_HOME:{temp_dir}}{/}.conan -;pytest --cov {envsitepackagesdir}/py3exiv2bind {posargs} [tox:jenkins] command = pytest -v