Skip to content
Merged

Dev #242

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.24)
project(pyexiv2bind)

find_package(Python3 COMPONENTS Interpreter Development)
find_package(Catch2)

if (WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_DEBUG_POSTFIX "d")
Expand All @@ -17,18 +18,12 @@ option(pyexiv2bind_build_tests "build test suite" ON)
include_directories(${CMAKE_BINARY_DIR})
include(FetchContent)
FetchContent_Declare(libpybind11
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.10.4.tar.gz
URL_HASH SHA1=5c366a92fc4b3937bcc3389405edbe362b1f3cbd
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.13.6.tar.gz
URL_HASH SHA1=8c7e3e8fec829ced31a495dec281153511f33c63
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
EXCLUDE_FROM_ALL
)

FetchContent_Declare(libcatch2
URL https://github.com/catchorg/Catch2/archive/v3.7.1.tar.gz
URL_HASH SHA1=0c67df1524fd3ce88f656a3865ba4d4e4886168f
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)

if(pyexiv2bind_generate_python_bindings)
FetchContent_MakeAvailable(libpybind11)
endif(pyexiv2bind_generate_python_bindings)
Expand Down
447 changes: 247 additions & 200 deletions Jenkinsfile

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Include the license file
include tox.ini CHANGELOG.rst README.rst CMakeLists.txt tests/CMakeLists.txt
include conanfile.py
include conanfile.py conan.lock
include src/py3exiv2bind/core.pyi
include patches/*.patch
include patches/*.cmake
Expand Down
3 changes: 2 additions & 1 deletion ci/docker/linux/jenkins/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ ARG PIP_INDEX_URL
ARG CONAN_USER_HOME
ARG CONAN_DOWNLOAD_CACHE=/tmp/conan_download_cache
ARG CONAN_CENTER_PROXY_V2_URL
COPY conanfile.py /tmp/conanfile.py
ARG UV_CACHE_DIR
ARG PIP_DOWNLOAD_CACHE
COPY --from=uv_builder /uv /uvx /bin/
Expand All @@ -73,6 +72,8 @@ RUN --mount=type=cache,target=${PIP_DOWNLOAD_CACHE} \
--mount=type=cache,target=${CONAN_DOWNLOAD_CACHE} \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=conanfile.py,target=/tmp/conanfile.py \
--mount=type=bind,source=conan.lock,target=/tmp/conan.lock \
uv run --only-group conan conan profile detect --exist-ok && \
cp ${CONAN_HOME}/global.conf /tmp/global.conf.original && \
echo "core.sources:download_cache = $CONAN_DOWNLOAD_CACHE" >> ${CONAN_HOME}/global.conf && \
Expand Down
3 changes: 2 additions & 1 deletion ci/docker/linux/tox/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ ARG CONAN_HOME
COPY ci/docker/linux/tox/conan/profile.ini ${CONAN_HOME}/profiles/default
COPY ci/docker/shared/conan/remotes.json ${CONAN_HOME}/remotes.json

COPY conanfile.py /tmp/conanfile.py
ARG UV_CACHE_DIR
ARG PIP_DOWNLOAD_CACHE
ARG CONAN_CENTER_PROXY_V2_URL
Expand All @@ -52,6 +51,8 @@ RUN --mount=type=cache,target=${PIP_DOWNLOAD_CACHE} \
--mount=type=cache,target=${CONAN_DOWNLOAD_CACHE} \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=conanfile.py,target=/tmp/conanfile.py \
--mount=type=bind,source=conan.lock,target=/tmp/conan.lock \
uv run --only-group conan conan profile detect --exist-ok && \
cp ${CONAN_HOME}/global.conf /tmp/global.conf.original && \
echo "core.sources:download_cache = $CONAN_DOWNLOAD_CACHE" >> ${CONAN_HOME}/global.conf && \
Expand Down
2 changes: 1 addition & 1 deletion cmake_scripts/external_exiv22.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ FetchContent_Declare(
# URL https://github.com/Exiv2/exiv2/archive/refs/tags/v0.28.1.tar.gz
# URL_HASH SHA256=3078651f995cb6313b1041f07f4dd1bf0e9e4d394d6e2adc6e92ad0b621291fa
GIT_REPOSITORY https://github.com/Exiv2/exiv2.git
GIT_TAG v0.28.1
GIT_TAG v0.28.7
# GIT_REPOSITORY https://github.com/Exiv2/exiv2.git
# GIT_TAG ${EXIV2_VERSION_TAG}
SYSTEM
Expand Down
15 changes: 15 additions & 0 deletions conan.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "0.5",
"requires": [
"zlib/1.3.1#b8bc2603263cf7eccbd6e17e66b0ed76%1755184481.162043",
"libiconv/1.17#1e65319e945f2d31941a9d28cc13c058%1755178573.409999",
"expat/2.5.0#91e43e4544923e4c934bfad1fa4306f9%1755186526.919869",
"catch2/3.11.0#a560b55882ff2deb1f4bafad832a1b98%1763673919.270116",
"brotli/1.0.9#8419c3e664bc762bc479561c5c7d2274%1755186526.576017"
],
"build_requires": [
"cmake/3.31.9#f9b9bb4bdfa37937619a33e9218703a6%1761647880.115"
],
"python_requires": [],
"config_requires": []
}
3 changes: 3 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def requirements(self):
self.requires("zlib/1.3.1")
if self.settings.os in ["Macos", "Linux"]:
self.requires("libiconv/1.17")

def build_requirements(self):
self.test_requires('catch2/3.11.0')
def imports(self):
self.copy("*.dll", dst="bin", src="bin") # From bin to bin
self.copy("*.dylib*", dst=".", src="lib") # From lib to bin
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[build-system]
requires = [
"setuptools>=77.0.0",
"wheel",
"ninja",
"uiucprescon.build @ https://github.com/UIUCLibrary/uiucprescon_build/releases/download/v0.4.0/uiucprescon_build-0.4.0-py3-none-any.whl",
"pybind11>=2.13",
"uiucprescon.build @ https://github.com/UIUCLibrary/uiucprescon_build/releases/download/v0.4.2/uiucprescon_build-0.4.2-py3-none-any.whl",
"cmake<4.0",
# "conan>=1.50.0,<2.0"
"conan>=2.0"
]
build-backend = "uiucprescon.build"
Expand Down
3 changes: 2 additions & 1 deletion scripts/resources/package_for_linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ ARG UV_INDEX_URL

COPY scripts/resources/package_for_linux/conan/profile.ini ${CONAN_HOME}/profiles/default
COPY ci/docker/shared/conan/remotes.json ${CONAN_HOME}/remotes.json
COPY conanfile.py /tmp/conanfile.py
COPY ci/docker/linux/tox/update_conan_compiler.py /tmp/update_conan_compiler.py
ARG UV_CACHE_DIR
ARG PIP_DOWNLOAD_CACHE
Expand All @@ -54,6 +53,8 @@ RUN --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=cache,target=${PIP_DOWNLOAD_CACHE} \
--mount=type=cache,target=${UV_CACHE_DIR} \
--mount=type=bind,source=conanfile.py,target=/tmp/conanfile.py \
--mount=type=bind,source=conan.lock,target=/tmp/conan.lock \
uv run --only-group conan conan profile detect --exist-ok && \
cp ${CONAN_HOME}/global.conf /tmp/global.conf.original && \
echo "core.sources:download_cache = $CONAN_DOWNLOAD_CACHE" >> ${CONAN_HOME}/global.conf && \
Expand Down
14 changes: 8 additions & 6 deletions scripts/resources/windows/tox/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ARG chocolateyVersion
FROM ${FROM_IMAGE} AS certsgen
RUN certutil -generateSSTFromWU roots.sst

FROM ${FROM_IMAGE} AS BASE_BUILDER
FROM ${FROM_IMAGE} AS base_builder


SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
Expand Down Expand Up @@ -62,13 +62,13 @@ RUN Set-ExecutionPolicy Bypass -Scope Process -Force; `


# ==============================================================================
FROM BASE_BUILDER AS CONAN_BUILDER
FROM base_builder AS conan_builder
ARG CONAN_HOME
ARG PIP_EXTRA_INDEX_URL
ARG PIP_INDEX_URL
ENV UV_FROZEN=1

COPY conanfile.py c:/temp/conanfile.py
COPY conanfile.py conan.lock c:/temp/
COPY ci/docker/shared/conan/remotes.json ${CONAN_HOME}/remotes.json
COPY scripts/resources/windows/tox/conan/profile.ini ${CONAN_HOME}/profiles/default
COPY scripts/resources/windows/tox/conan/python.ini ${CONAN_HOME}/profiles/python
Expand All @@ -82,17 +82,19 @@ RUN uv run --only-group conan conan profile detect --exist-ok ; `
Copy-Item -Path "${Env:CONAN_HOME}\remotes.json" -Destination "c:\remotes.json" ; `
uv run --only-group conan conan remote update conan-center --url ${env:CONAN_CENTER_PROXY_V2_URL}; `
}; `
uv run --only-group conan conan install c:/temp/ -pr:h=default -pr:b=python; `
uv run --only-group conan conan install c:/temp/ -pr:h=default -pr:b=python -of c:/temp/delme; `
if ($LASTEXITCODE -ne 0) { `
throw \"Command 'conan install' failed with exit code: $LASTEXITCODE\"`
} ;`
Remove-Item -Path "c:\temp\delme" -Recurse -Force ; `
uv run --only-group conan conan cache clean "*" -b --source --build --temp ; `
Remove-Item -Path "${env:UV_PROJECT}\.venv" -Recurse -Force ; `
uv cache clean --no-progress ; `
if (${env:CONAN_CENTER_PROXY_V2_URL} -ne $(Get-Content -Raw -Path ${Env:CONAN_HOME}\remotes.json)) { `
Move-Item -Path "c:\remotes.json" -Destination "${Env:CONAN_HOME}\remotes.json" -Force ;`
}

FROM BASE_BUILDER
FROM base_builder
COPY --from=certsgen c:/roots.sst c:/roots.sst
RUN certutil -addstore -f root c:/roots.sst ; `
del c:/roots.sst
Expand All @@ -102,7 +104,7 @@ ARG UV_CACHE_DIR
RUN New-Item -type directory -path ${Env:PIP_DOWNLOAD_CACHE} -Force | Out-Null ; `
New-Item -type directory -path ${Env:UV_CACHE_DIR} -Force | Out-Null
ARG CONAN_HOME
COPY --from=CONAN_BUILDER ${CONAN_HOME}/ ${CONAN_HOME}/
COPY --from=conan_builder ${CONAN_HOME}/ ${CONAN_HOME}/
ARG CONAN_USER_HOME
ENV CONAN_USER_HOME=${CONAN_USER_HOME}`
CONAN_HOME=${CONAN_HOME}`
Expand Down
1 change: 0 additions & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ sonar.links.scm=https://github.com/UIUCLibrary/pyexiv2bind
sonar.links.homepage=https://github.com/UIUCLibrary/pyexiv2bind
sonar.tests=tests
sonar.scm.provider=git
sonar.python.coverage.reportPaths=reports/coverage/coverage-python.xml,reports/coverage/coverage_cpp_sonar.xml
sonar.python.flake8.reportPaths=logs/flake8.log
sonar.python.pylint.reportPaths=reports/pylint.txt
sonar.python.version=3
Expand Down
2 changes: 1 addition & 1 deletion src/py3exiv2bind/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (pyexiv2bind_generate_python_bindings)
Python3_add_library(core core.cpp $<TARGET_OBJECTS:glue> )
set_target_properties(core PROPERTIES EXCLUDE_FROM_ALL on)
add_custom_command(TARGET core
POST_BUILD
POST_BUILD
COMMAND ${Python3_EXECUTABLE} setup.py build_py --build-lib ${PROJECT_BINARY_DIR}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
Expand Down
8 changes: 5 additions & 3 deletions src/py3exiv2bind/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
#include "glue/glue.h"
#include "glue/Image.h"
#include "glue/glue_execeptions.h"
#include <string>
#include <exiv2/error.hpp>
#include <pybind11/pybind11.h>
#include <pybind11/pytypes.h>
#include <pybind11/stl.h>

// PyBind11 library generates warnings for clang-tidy that I can't do anything about
// NOLINTNEXTLINE
PYBIND11_MODULE(core, m) {
PYBIND11_MODULE(core, m, pybind11::mod_gil_not_used()){
pybind11::options options;
options.enable_function_signatures();
m.doc() = R"pbdoc(
Expand All @@ -21,8 +23,8 @@ PYBIND11_MODULE(core, m) {
m.def("exiv2_version", &exiv2_version, "Version of exiv2 that is built with");
pybind11::class_<Image>(m, "Image", "The c++ binding for libexiv2")
.def(pybind11::init<const std::string &>())
.def_property_readonly("filename", [](const Image &i) {
return pybind11::str(i.getFilename());
.def_property_readonly("filename", [](const Image &img) {
return pybind11::str(img.getFilename());
}, "Name of file loaded")
.def_property_readonly("pixelHeight", &Image::get_pixelHeight, "Number of pixels high")
.def_property_readonly("pixelWidth", &Image::get_pixelWidth, "Number of pixels wide")
Expand Down
9 changes: 4 additions & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include(FetchContent)
if (BUILD_TESTING)

if (BUILD_TESTING AND Catch2_FOUND)
include(Catch)
FetchContent_Declare(test_images
URL https://nexus.library.illinois.edu/repository/sample-data/images/sample_images.tar.gz
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/sample_images
Expand All @@ -19,6 +19,7 @@ if (BUILD_TESTING)
)
add_dependencies(add_python_tests core)
add_custom_command(TARGET add_python_tests
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/conftest.py ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/test_core.py ${CMAKE_CURRENT_BINARY_DIR}
# COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/test_common.py ${CMAKE_CURRENT_BINARY_DIR}
Expand Down Expand Up @@ -50,8 +51,6 @@ if (BUILD_TESTING)
endif()
endif()

FetchContent_MakeAvailable(libcatch2)
FetchContent_GetProperties(libcatch2)
list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras)
add_executable(cpp_tests
test_basic.cpp
Expand All @@ -68,8 +67,8 @@ if (BUILD_TESTING)
)
target_include_directories(cpp_tests PRIVATE ${PROJECT_SOURCE_DIR}/src/py3exiv2bind/core)
target_link_libraries(cpp_tests PRIVATE Catch2::Catch2WithMain exiv2lib)
include(Catch)

list(APPEND CMAKE_MODULE_PATH ${catch_SOURCE_DIR}/contrib/)
catch_discover_tests(cpp_tests TEST_PREFIX ${PROJECT_NAME}::test-pyexiv2::)
add_executable(test_editing
test_editing.cpp
Expand Down
6 changes: 3 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading