diff --git a/GUI/Model/Job/ParameterTreeBuilder.h b/GUI/Model/Job/ParameterTreeBuilder.h index c13663f7b62914615f976d0e37b5c5559ff263c3..d6222fa9061329dd99a40ab364ba9d8c4a5d1ebc 100644 --- a/GUI/Model/Job/ParameterTreeBuilder.h +++ b/GUI/Model/Job/ParameterTreeBuilder.h @@ -2,7 +2,7 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/Model/Model/ParameterTreeBuilder.h +//! @file GUI/Model/Job/ParameterTreeBuilder.h //! @brief Defines class ParameterTreeBuilder. //! //! @homepage http://www.bornagainproject.org diff --git a/PyCore/Embed/PyCore.h b/PyCore/Embed/PyCore.h index 1b634834a1f04b6483ea28a99acdf6ba7d9bcafe..7834e4302a26d3ab19b05c15f1d587597404cd8f 100644 --- a/PyCore/Embed/PyCore.h +++ b/PyCore/Embed/PyCore.h @@ -24,33 +24,17 @@ #undef _POSIX_C_SOURCE #undef _XOPEN_SOURCE +#define PY_SSIZE_T_CLEAN + + #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif -#define PY_SSIZE_T_CLEAN - #include <Python.h> -#ifdef INCLUDE_NUMPY - -#ifdef BORNAGAIN_PYTHON_API_SWIG - -// NOTE: Using `PY_ARRAY_UNIQUE_SYMBOL` and `NO_IMPORT_ARRAY` one can use -// the Numpy Array API in multiple files for a single extension module. -#define PY_ARRAY_UNIQUE_SYMBOL BORNAGAIN_PYTHONAPI_ARRAY -#define NO_IMPORT_ARRAY - -#endif // BORNAGAIN_PYTHON_API_SWIG - -#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION // to prevent spurious warning - -#include <numpy/arrayobject.h> - -#endif // INCLUDE_NUMPY - #ifdef __GNUC__ #pragma GCC diagnostic pop #endif diff --git a/PyCore/Embed/PyInterpreter.cpp b/PyCore/Embed/PyInterpreter.cpp index 04fcd2faa9d3f2182a31391ce08f63ae85290a02..58571b46d25f9d503258cb382ae1f833e0f265e9 100644 --- a/PyCore/Embed/PyInterpreter.cpp +++ b/PyCore/Embed/PyInterpreter.cpp @@ -27,15 +27,10 @@ References: - Python's garbage collector <https://rushter.com/blog/python-garbage-collector> */ -#define INCLUDE_NUMPY // also include Numpy via PyCore - -#include "PyCore/Embed/PyCore.h" - -#undef INCLUDE_NUMPY - -#include "Base/Util/Assert.h" #include "PyCore/Embed/PyInterpreter.h" +#include "Base/Util/Assert.h" #include "PyCore/Embed/PyObjectPtr.h" +#include "PyCore/Embed/WithNumpy.h" #include <algorithm> // transform #include <cstddef> // NULL #include <cstring> // memcpy diff --git a/PyCore/Embed/WithNumpy.h b/PyCore/Embed/WithNumpy.h new file mode 100644 index 0000000000000000000000000000000000000000..a61f22a9fb6a7f00d9edf33507dea462fa1af579 --- /dev/null +++ b/PyCore/Embed/WithNumpy.h @@ -0,0 +1,54 @@ +// ************************************************************************************************ +// +// BornAgain: simulate and fit reflection and scattering +// +//! @file PyCore/Embed/WithNumpy.h +//! @brief Includes python header and takes care of warnings. +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2023 +//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) +// +// ************************************************************************************************ + +#ifndef BORNAGAIN_PYTHON +#error this header requires Python support +#endif +#ifdef SWIG +#error no need to expose this header to Swig +#endif +#ifndef BORNAGAIN_PYCORE_EMBED_WITHNUMPY_H +#define BORNAGAIN_PYCORE_EMBED_WITHNUMPY_H + +#undef _POSIX_C_SOURCE +#undef _XOPEN_SOURCE + +#define PY_SSIZE_T_CLEAN + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + +#include <Python.h> + +#ifdef BORNAGAIN_PYTHON_API_SWIG + +// NOTE: Using `PY_ARRAY_UNIQUE_SYMBOL` and `NO_IMPORT_ARRAY` one can use +// the Numpy Array API in multiple files for a single extension module. +#define PY_ARRAY_UNIQUE_SYMBOL BORNAGAIN_PYTHONAPI_ARRAY +#define NO_IMPORT_ARRAY + +#endif // BORNAGAIN_PYTHON_API_SWIG + +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION // to prevent spurious warning + +#include <numpy/arrayobject.h> + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + +#endif // BORNAGAIN_PYCORE_EMBED_WITHNUMPY_H