Skip to content

Commit c6c5cc6

Browse files
committed
Split Python- and NumPy-related object converters.
This allows the tkagg extension to build correctly without adding a NumPy dependency.
1 parent 7bba912 commit c6c5cc6

9 files changed

+611
-579
lines changed

setupext.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,11 @@ def get_extensions(self):
337337
# agg
338338
ext = Extension(
339339
"matplotlib.backends._backend_agg", [
340+
"src/_backend_agg_wrapper.cpp",
341+
"src/_backend_agg.cpp",
340342
"src/mplutils.cpp",
341343
"src/py_converters.cpp",
342-
"src/_backend_agg.cpp",
343-
"src/_backend_agg_wrapper.cpp",
344+
"src/numpy_converters.cpp",
344345
])
345346
add_numpy_flags(ext)
346347
add_libagg_flags_and_sources(ext)
@@ -379,19 +380,21 @@ def get_extensions(self):
379380
# image
380381
ext = Extension(
381382
"matplotlib._image", [
383+
"src/_image_wrapper.cpp",
382384
"src/_image.cpp",
383385
"src/mplutils.cpp",
384-
"src/_image_wrapper.cpp",
385386
"src/py_converters.cpp",
387+
"src/numpy_converters.cpp",
386388
])
387389
add_numpy_flags(ext)
388390
add_libagg_flags_and_sources(ext)
389391
yield ext
390392
# path
391393
ext = Extension(
392394
"matplotlib._path", [
393-
"src/py_converters.cpp",
394395
"src/_path_wrapper.cpp",
396+
"src/py_converters.cpp",
397+
"src/numpy_converters.cpp",
395398
])
396399
add_numpy_flags(ext)
397400
add_libagg_flags_and_sources(ext)
@@ -414,7 +417,6 @@ def get_extensions(self):
414417
libraries=({"linux": ["dl"], "win32": ["psapi"],
415418
"cygwin": ["psapi"]}.get(sys.platform, [])),
416419
extra_link_args={"win32": ["-mwindows"]}.get(sys.platform, []))
417-
add_numpy_flags(ext)
418420
add_libagg_flags(ext)
419421
yield ext
420422
# tri

src/_backend_agg_wrapper.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "mplutils.h"
2-
#include "numpy_cpp.h"
32
#include "py_converters.h"
3+
#include "numpy_cpp.h"
4+
#include "numpy_converters.h"
45
#include "_backend_agg.h"
56

67
typedef struct

src/_image_wrapper.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#include "mplutils.h"
22
#include "_image_resample.h"
33
#include "_image.h"
4-
#include "numpy_cpp.h"
54
#include "py_converters.h"
5+
#include "numpy_cpp.h"
6+
#include "numpy_converters.h"
67

78

89
/**********************************************************************

src/_path_wrapper.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
#include "_path.h"
44

5-
#include "py_converters.h"
65
#include "py_adaptors.h"
6+
#include "py_converters.h"
7+
#include "numpy_converters.h"
78

89
PyObject *convert_polygon_vector(std::vector<Polygon> &polygons)
910
{

src/_tkagg.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
#define dlsym GetProcAddress
3434
#else
3535
#include <dlfcn.h>
36-
// Suppress -Wunused-function on POSIX, but not on Windows where that would
37-
// lead to PY_ARRAY_UNIQUE_SYMBOL being an unresolved external.
38-
#define NO_IMPORT_ARRAY
3936
#endif
4037

4138
// Include our own excerpts from the Tcl / Tk headers

0 commit comments

Comments
 (0)