Skip to content

Commit ed5a55e

Browse files
jmcarcelltmadlener
authored andcommitted
Forward-declare PyObject not to have to include Python.h
1 parent 5d82748 commit ed5a55e

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ 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
30+
target_include_directories(${libname} SYSTEM PRIVATE
3131
${Python3_INCLUDE_DIRS}
3232
)
3333

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)