From 3429948100a535d4b65cf2429e3c665bdb234e17 Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Fri, 11 Aug 2023 17:52:09 -0700 Subject: [PATCH] Simplify and fix versioning (#173) --- CMakeLists.txt | 8 +------- src/Base/CMakeLists.txt | 1 + src/Base/Version.cpp | 17 +++++++++++++++++ src/pyAMReX.cpp | 10 ++-------- 4 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 src/Base/Version.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 48927060..af41a817 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,8 +59,6 @@ option(pyAMReX_IPO ON ) -set(pyAMReX_VERSION_INFO "" CACHE STRING - "PEP-440 conformant version (set by distutils)") # change the default build type to Release (or RelWithDebInfo) instead of Debug set_default_build_type("Release") @@ -185,11 +183,7 @@ endforeach() # Defines ##################################################################### # -# for module __version__ -foreach(D IN LISTS AMReX_SPACEDIM) - target_compile_definitions(pyAMReX_${D}d PRIVATE - PYAMReX_VERSION_INFO=${pyAMReX_VERSION_INFO}) -endforeach() +# none needed - please use AMReX_Config.H # Warnings #################################################################### diff --git a/src/Base/CMakeLists.txt b/src/Base/CMakeLists.txt index ada9fb5f..1abb96c8 100644 --- a/src/Base/CMakeLists.txt +++ b/src/Base/CMakeLists.txt @@ -24,5 +24,6 @@ foreach(D IN LISTS AMReX_SPACEDIM) PODVector.cpp Utility.cpp Vector.cpp + Version.cpp ) endforeach() diff --git a/src/Base/Version.cpp b/src/Base/Version.cpp new file mode 100644 index 00000000..4b4717cf --- /dev/null +++ b/src/Base/Version.cpp @@ -0,0 +1,17 @@ +/* Copyright 2021-2023 The AMReX Community + * + * License: BSD-3-Clause-LBNL + * Authors: Axel Huebl + */ +#include "pyAMReX.H" + +#include +#include + + +void init_Version (py::module& m) +{ + // API runtime version + // note PEP-440 syntax: x.y.zaN but x.y.z.devN + m.attr("__version__") = amrex::Version(); +} diff --git a/src/pyAMReX.cpp b/src/pyAMReX.cpp index 4de4333a..ef8b3d63 100644 --- a/src/pyAMReX.cpp +++ b/src/pyAMReX.cpp @@ -41,6 +41,7 @@ void init_PlotFileUtil(py::module &); void init_PODVector(py::module &); void init_Utility(py::module &); void init_Vector(py::module &); +void init_Version(py::module &); #if AMREX_SPACEDIM == 1 @@ -117,14 +118,7 @@ PYBIND11_MODULE(amrex_3d_pybind, m) { // Wrappers around standalone functions init_PlotFileUtil(m); init_Utility(m); - - // API runtime version - // note PEP-440 syntax: x.y.zaN but x.y.z.devN -#ifdef PYAMReX_VERSION_INFO - m.attr("__version__") = MACRO_STRINGIFY(PYAMReX_VERSION_INFO); -#else - m.attr("__version__") = "dev"; -#endif + init_Version(m); // authors m.attr("__author__") =