File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,22 @@ The C++-part of the library consists of the single header file `matplotlibcpp.h`
103
103
anywhere.
104
104
Since a python interpreter is opened internally, it is necessary to link against ` libpython2.7 ` in order to use
105
105
matplotlib-cpp.
106
- (There should be no problems using python3 instead of python2.7, if desired)
106
+
107
+ # Python 3
108
+
109
+ The code is written in a way that should support both python2 and python3.
110
+ By default, matplotlib-cpp will try to "just work" and include the header ` python2.7/Python.h ` .
111
+
112
+ To modify this behaviour the define ` MATPLOTLIBCPP_PYTHON_HEADER ` ,
113
+ can be set to an absolute or relative path:
114
+
115
+ #define MATPLOTLIBCPP_PYTHON_HEADER /usr/include/python3.6/Python.h
116
+ #include "matplotlibcpp.h"
117
+
118
+ or
119
+
120
+ g++ -DMATPLOTLIBCPP_PYTHON_HEADER=Python.h -I/usr/include/python3.6 <...>
121
+
107
122
108
123
Why?
109
124
----
Original file line number Diff line number Diff line change 10
10
#include < functional>
11
11
#endif
12
12
13
- #ifdef PY_INCLUDE
14
- #include < Python.h>
15
- #else
13
+ // i.e. g++ -DMATPLOTLIBCPP_PYTHON_HEADER=/usr/include/python3.6/Python.h [...]
14
+ #ifdef MATPLOTLIBCPP_PYTHON_HEADER
15
+ #define STRINGIFY_ (x ) #x
16
+ #define STRINGIFY (x ) STRINGIFY_(x)
17
+ #include STRINGIFY(MATPLOTLIBCPP_PYTHON_HEADER)
18
+ #else // This should stay the default for backwards compatibility
16
19
#include < python2.7/Python.h>
17
20
#endif
18
21
You can’t perform that action at this time.
0 commit comments