itom
Loading...
Searching...
No Matches
pythonWrapper.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2022, Institut für Technische Optik (ITO),
5 Universität Stuttgart, Germany
6
7 This file is part of itom.
8
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13
14 itom is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17 General Public Licence for more details.
18
19 You should have received a copy of the GNU Library General Public License
20 along with itom. If not, see <http://www.gnu.org/licenses/>.
21*********************************************************************** */
22
23// python
24#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
25
26//
27// see http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=7f3f750596a105d48ea84ebfe1b1c4ca03e0bab3
28#if (defined _DEBUG) && (defined WIN32)
29 // see https://github.com/microsoft/onnxruntime/issues/9735#issuecomment-970718821
30 #include <corecrt.h>
31 #undef _DEBUG
32
33 // work around following: https://stackoverflow.com/questions/23068700/embedding-python3-in-qt-5
34 #pragma push_macro("slots")
35 #undef slots
36 #include "Python.h"
37 #include "numpy/arrayobject.h"
38 #include "numpy/arrayscalars.h"
39 #include "datetime.h"
40 #pragma pop_macro("slots")
41
42 #define _DEBUG
43#else
44 // work around following: https://stackoverflow.com/questions/23068700/embedding-python3-in-qt-5
45 #pragma push_macro("slots")
46 #undef slots
47 #include "Python.h"
48 #include "numpy/arrayobject.h"
49 #include "numpy/arrayscalars.h"
50 #include "datetime.h"
51 #pragma pop_macro("slots")
52#endif
53
54
55// use this macro if a method of the C-API of the Python datetime module should be used.
56#define Itom_PyDateTime_IMPORT \
57 if (PyDateTimeAPI == nullptr) \
58 { \
59 PyDateTime_IMPORT; \
60 }