Skip to content

Commit b5056e2

Browse files
authored
Forward-declare PyObject not to have to include Python.h (#910)
* Forward-declare PyObject not to have to include Python.h * Remove unnecessary target_include_directories for python --------- Co-authored-by: Juan Miguel Carceller <[email protected]>
1 parent 5d82748 commit b5056e2

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

include/podio/detail/Pythonizations.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
#define PODIO_DETAIL_PYTHONIZATIONS_H
33

44
#define PY_SSIZE_T_CLEAN
5-
#include <Python.h>
65
#include <string>
76

7+
typedef struct _object PyObject;
8+
89
namespace podio::detail::pythonizations {
910

1011
// Callback function for the subscript pythonization
@@ -16,4 +17,4 @@ void pythonize_subscript(PyObject* klass, const std::string& name);
1617

1718
} // namespace podio::detail::pythonizations
1819

19-
#endif // PODIO_DETAIL_PYTHONIZATIONS_H
20+
#endif // PODIO_DETAIL_PYTHONIZATIONS_H

src/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ FUNCTION(PODIO_ADD_LIB_AND_DICT libname headers sources selection )
2727
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
2828
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
2929
)
30-
target_include_directories(${libname} SYSTEM PUBLIC
31-
${Python3_INCLUDE_DIRS}
32-
)
3330

3431
# dictionary
3532
set(dictname ${libname}Dict)

src/Pythonizations.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <cstring>
44
#include <stdexcept>
55

6+
#include <Python.h>
7+
68
namespace podio::detail::pythonizations {
79

810
// Callback function for the subscript pythonization
@@ -52,4 +54,4 @@ void pythonize_subscript(PyObject* klass, const std::string& name) {
5254
Py_DECREF(method);
5355
}
5456

55-
} // namespace podio::detail::pythonizations
57+
} // namespace podio::detail::pythonizations

0 commit comments

Comments
 (0)