Skip to content

Commit

Permalink
Split Python- and NumPy-related object converters.
Browse files Browse the repository at this point in the history
This allows the tkagg extension to build correctly without adding a
NumPy dependency.
  • Loading branch information
QuLogic committed Jan 14, 2021
1 parent 7bba912 commit c6c5cc6
Show file tree
Hide file tree
Showing 9 changed files with 611 additions and 579 deletions.
12 changes: 7 additions & 5 deletions setupext.py
Expand Up @@ -337,10 +337,11 @@ def get_extensions(self):
# agg
ext = Extension(
"matplotlib.backends._backend_agg", [
"src/_backend_agg_wrapper.cpp",
"src/_backend_agg.cpp",
"src/mplutils.cpp",
"src/py_converters.cpp",
"src/_backend_agg.cpp",
"src/_backend_agg_wrapper.cpp",
"src/numpy_converters.cpp",
])
add_numpy_flags(ext)
add_libagg_flags_and_sources(ext)
Expand Down Expand Up @@ -379,19 +380,21 @@ def get_extensions(self):
# image
ext = Extension(
"matplotlib._image", [
"src/_image_wrapper.cpp",
"src/_image.cpp",
"src/mplutils.cpp",
"src/_image_wrapper.cpp",
"src/py_converters.cpp",
"src/numpy_converters.cpp",
])
add_numpy_flags(ext)
add_libagg_flags_and_sources(ext)
yield ext
# path
ext = Extension(
"matplotlib._path", [
"src/py_converters.cpp",
"src/_path_wrapper.cpp",
"src/py_converters.cpp",
"src/numpy_converters.cpp",
])
add_numpy_flags(ext)
add_libagg_flags_and_sources(ext)
Expand All @@ -414,7 +417,6 @@ def get_extensions(self):
libraries=({"linux": ["dl"], "win32": ["psapi"],
"cygwin": ["psapi"]}.get(sys.platform, [])),
extra_link_args={"win32": ["-mwindows"]}.get(sys.platform, []))
add_numpy_flags(ext)
add_libagg_flags(ext)
yield ext
# tri
Expand Down
3 changes: 2 additions & 1 deletion src/_backend_agg_wrapper.cpp
@@ -1,6 +1,7 @@
#include "mplutils.h"
#include "numpy_cpp.h"
#include "py_converters.h"
#include "numpy_cpp.h"
#include "numpy_converters.h"
#include "_backend_agg.h"

typedef struct
Expand Down
3 changes: 2 additions & 1 deletion src/_image_wrapper.cpp
@@ -1,8 +1,9 @@
#include "mplutils.h"
#include "_image_resample.h"
#include "_image.h"
#include "numpy_cpp.h"
#include "py_converters.h"
#include "numpy_cpp.h"
#include "numpy_converters.h"


/**********************************************************************
Expand Down
3 changes: 2 additions & 1 deletion src/_path_wrapper.cpp
Expand Up @@ -2,8 +2,9 @@

#include "_path.h"

#include "py_converters.h"
#include "py_adaptors.h"
#include "py_converters.h"
#include "numpy_converters.h"

PyObject *convert_polygon_vector(std::vector<Polygon> &polygons)
{
Expand Down
3 changes: 0 additions & 3 deletions src/_tkagg.cpp
Expand Up @@ -33,9 +33,6 @@
#define dlsym GetProcAddress
#else
#include <dlfcn.h>
// Suppress -Wunused-function on POSIX, but not on Windows where that would
// lead to PY_ARRAY_UNIQUE_SYMBOL being an unresolved external.
#define NO_IMPORT_ARRAY
#endif

// Include our own excerpts from the Tcl / Tk headers
Expand Down

0 comments on commit c6c5cc6

Please sign in to comment.