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`
103103anywhere.
104104Since a python interpreter is opened internally, it is necessary to link against ` libpython2.7 ` in order to use
105105matplotlib-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+
107122
108123Why?
109124----
Original file line number Diff line number Diff line change 1010#include < functional>
1111#endif
1212
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
1619#include < python2.7/Python.h>
1720#endif
1821
You can’t perform that action at this time.
0 commit comments