diff --git a/CHANGELOG.md b/CHANGELOG.md index 67fb11f..29c278a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.5.1.1] - 2024-03-29 + +Minor fixes to allow linking against QuantLib-Risks without duplicate symbols. + ## [1.5.1] - 2024-03-28 Initial release of Python bindings for XAD. +[1.5.1.1]: https://github.com/auto-differentiation/xad-py/compare/v1.5.1...v1.5.1.1 [1.5.1]: https://github.com/auto-differentiation/xad-py/releases/tag/v1.5.1 diff --git a/pyproject.toml b/pyproject.toml index 607eecb..433e62d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ [tool.poetry] name = "xad" -version = "1.5.1" +version = "1.5.1.1" description = "High-Performance Automatic Differentiation for Python" authors = ["Auto Differentiation Dev Team "] readme = "README.md" @@ -102,6 +102,10 @@ requires = [ ] build-backend = "poetry.core.masonry.api" +[tool.pytest.ini_options] +minversion = "6.0" +testpaths = ["tests"] + [tool.black] line-length = 100 target-version = ["py38", "py39", "py310", "py311", "py312"] diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 835752c..10f698d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,16 +26,47 @@ if(MSVC) option(XAD_STATIC_MSVC_RUNTIME "Use static runtime" ON) endif() +find_package(Threads REQUIRED) + add_subdirectory(pybind11) add_subdirectory(xad) -pybind11_add_module(_xad module.cpp math.hpp tape.hpp real.hpp exceptions.hpp) -target_link_libraries(_xad PRIVATE XAD::xad) -target_compile_definitions(_xad PRIVATE VERSION_INFO=${PROJECT_VERSION}) +# Note: We bake XAD directly into this module, rather than linking, since +# otherwise we get conflicting definitions of the types when used in +# QuantLib-Risks-Py which causes a segfault We assume a platform that at least +# supports the AVX instructions set + +pybind11_add_module( + _xad + module.cpp + math.hpp + tape.hpp + real.hpp + exceptions.hpp + xad/src/Tape.cpp) +target_include_directories(_xad PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/xad/src + xad/src) +set_target_properties(_xad PROPERTIES CXX_STANDARD 17) if(MSVC) - # to allow using M_PI and the like - target_compile_definitions(_xad PRIVATE _USE_MATH_DEFINES) + target_compile_options(_xad PRIVATE -nologo -utf-8 "/arch:AVX") + target_compile_definitions( + _xad + PRIVATE VERSION_INFO=${PROJECT_VERSION} + _UNICODE + UNICODE + WIN32_LEAN_AND_MEAN + WIN32 + _WIN32 + _USE_MATH_DEFINES) + # static MSVC runtime to avoid linking issues in Python and QuantLib-Risks set_target_properties(_xad PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + target_compile_options(_xad PRIVATE -mavx -stdlib=libc++ + -mmacosx-version-min=10.9) + target_compile_definitions(_xad PRIVATE VERSION_INFO=${PROJECT_VERSION}) +else() + target_compile_options(_xad PRIVATE -mavx) + target_compile_definitions(_xad PRIVATE VERSION_INFO=${PROJECT_VERSION}) endif()