Skip to content

Commit

Permalink
Fix: impactx.__version__
Browse files Browse the repository at this point in the history
Set a default value and fallback.
  • Loading branch information
ax3l committed Jan 2, 2024
1 parent 8d040b7 commit d8444f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ option(ImpactX_amrex_internal "Download & build AMReX" ON)
option(ImpactX_openpmd_internal "Download & build openPMD-api" ON)
option(ImpactX_pyamrex_internal "Download & build pyAMReX" ON)

set(pyImpactX_VERSION_INFO "" CACHE STRING
set(pyImpactX_VERSION_INFO "${ImpactX_VERSION}" CACHE STRING
"PEP-440 conformant version (set by setup.py)")

# change the default build type to Release (or RelWithDebInfo) instead of Debug
Expand Down
12 changes: 10 additions & 2 deletions src/python/pyImpactX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include <ImpactX.H>
#include <particles/elements/All.H>

#ifndef PYIMPACTX_VERSION_INFO
# include <ImpactXVersion.H>
#endif

#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)

Expand All @@ -25,7 +29,7 @@ void init_transformation(py::module&);

PYBIND11_MODULE(impactx_pybind, m) {
// make sure AMReX types are known
py::module::import("amrex.space3d");
auto amr = py::module::import("amrex.space3d");

m.doc() = R"pbdoc(
impactx_pybind
Expand All @@ -47,12 +51,16 @@ PYBIND11_MODULE(impactx_pybind, m) {
init_transformation(m);
init_ImpactX(m);

// expose our amrex module
m.attr("amr") = amr;

// API runtime version
// note PEP-440 syntax: x.y.zaN but x.y.z.devN
#ifdef PYIMPACTX_VERSION_INFO
m.attr("__version__") = MACRO_STRINGIFY(PYIMPACTX_VERSION_INFO);
#else
m.attr("__version__") = "dev";
// note: not necessarily PEP-440 compliant
m.attr("__version__") = IMPACTX_VERSION;
#endif

// authors
Expand Down

0 comments on commit d8444f0

Please sign in to comment.