From 612856a0ba1599dd4ce17cb6a6251f17b639e860 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 25 Nov 2016 15:15:41 -0500 Subject: [PATCH 1/7] Fix invalid C prototype. Might be the only case of -Wstrict-prototypes being used. --- src/qhull_wrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qhull_wrap.c b/src/qhull_wrap.c index 3a24a7514551..06d278ebdd57 100644 --- a/src/qhull_wrap.c +++ b/src/qhull_wrap.c @@ -310,7 +310,7 @@ delaunay(PyObject *self, PyObject *args) /* Return qhull version string for assistance in debugging. */ static PyObject* -version() +version(void) { return PyBytes_FromString(qh_version); } From d5b150b7f87b7af33673f99bc011d8f93683f91f Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 25 Nov 2016 15:17:45 -0500 Subject: [PATCH 2/7] BLD: Fix removal of -Wstrict-prototypes option. Current releases of distutils (2.7 & 3.5, at least) import customize_compiler into the build_ext namespace, so changing the original doesn't actually have any effect. --- setupext.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/setupext.py b/setupext.py index f77e24555d40..e7d57894660c 100644 --- a/setupext.py +++ b/setupext.py @@ -3,6 +3,7 @@ from distutils import sysconfig from distutils import version from distutils.core import Extension +import distutils.command.build_ext import glob import multiprocessing import os @@ -228,8 +229,8 @@ def print_line(*args, **kwargs): print_status = print_message = print_raw = print_line -# Remove the -Wstrict-prototypesoption, is it's not valid for C++ -customize_compiler = sysconfig.customize_compiler +# Remove the -Wstrict-prototypes option, is it's not valid for C++ +customize_compiler = distutils.command.build_ext.customize_compiler def my_customize_compiler(compiler): @@ -240,7 +241,7 @@ def my_customize_compiler(compiler): pass return retval -sysconfig.customize_compiler = my_customize_compiler +distutils.command.build_ext.customize_compiler = my_customize_compiler def make_extension(name, files, *args, **kwargs): From 450f6f40b5461de49bf36d570efa3b805d59ecbc Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 25 Nov 2016 15:19:59 -0500 Subject: [PATCH 3/7] Remove unused variable. --- src/_path_wrapper.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/_path_wrapper.cpp b/src/_path_wrapper.cpp index 28fbaf282b57..a18b6bd24634 100644 --- a/src/_path_wrapper.cpp +++ b/src/_path_wrapper.cpp @@ -8,7 +8,6 @@ PyObject *convert_polygon_vector(std::vector &polygons) { PyObject *pyresult = PyList_New(polygons.size()); - bool fix_endpoints; for (size_t i = 0; i < polygons.size(); ++i) { Polygon poly = polygons[i]; From 99f63576e1ee0861537c5b42c7cc6c0a1809ddbc Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 25 Nov 2016 15:43:15 -0500 Subject: [PATCH 4/7] Fix misleading indentation warnings in Agg code. --- extern/agg24-svn/include/agg_span_gouraud_rgba.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/extern/agg24-svn/include/agg_span_gouraud_rgba.h b/extern/agg24-svn/include/agg_span_gouraud_rgba.h index 89192d227bee..1b2857202971 100644 --- a/extern/agg24-svn/include/agg_span_gouraud_rgba.h +++ b/extern/agg24-svn/include/agg_span_gouraud_rgba.h @@ -198,10 +198,10 @@ namespace agg vg = g.y(); vb = b.y(); va = a.y(); - if(vr < 0) vr = 0; if(vr > lim) vr = lim; - if(vg < 0) vg = 0; if(vg > lim) vg = lim; - if(vb < 0) vb = 0; if(vb > lim) vb = lim; - if(va < 0) va = 0; if(va > lim) va = lim; + if(vr < 0) { vr = 0; }; if(vr > lim) { vr = lim; }; + if(vg < 0) { vg = 0; }; if(vg > lim) { vg = lim; }; + if(vb < 0) { vb = 0; }; if(vb > lim) { vb = lim; }; + if(va < 0) { va = 0; }; if(va > lim) { va = lim; }; span->r = (value_type)vr; span->g = (value_type)vg; span->b = (value_type)vb; @@ -245,10 +245,10 @@ namespace agg vg = g.y(); vb = b.y(); va = a.y(); - if(vr < 0) vr = 0; if(vr > lim) vr = lim; - if(vg < 0) vg = 0; if(vg > lim) vg = lim; - if(vb < 0) vb = 0; if(vb > lim) vb = lim; - if(va < 0) va = 0; if(va > lim) va = lim; + if(vr < 0) { vr = 0; }; if(vr > lim) { vr = lim; }; + if(vg < 0) { vg = 0; }; if(vg > lim) { vg = lim; }; + if(vb < 0) { vb = 0; }; if(vb > lim) { vb = lim; }; + if(va < 0) { va = 0; }; if(va > lim) { va = lim; }; span->r = (value_type)vr; span->g = (value_type)vg; span->b = (value_type)vb; From ad050914b68cd32a8f40255f9bac9307a21553cd Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 25 Nov 2016 19:44:12 -0500 Subject: [PATCH 5/7] Fix warnings about incorrect format specifiers. --- src/_backend_agg_wrapper.cpp | 10 +++++----- src/_image_wrapper.cpp | 2 +- src/_path_wrapper.cpp | 2 +- src/py_converters.cpp | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/_backend_agg_wrapper.cpp b/src/_backend_agg_wrapper.cpp index 1b6bdc4cb463..f6ed42bcd277 100644 --- a/src/_backend_agg_wrapper.cpp +++ b/src/_backend_agg_wrapper.cpp @@ -459,14 +459,14 @@ PyRendererAgg_draw_gouraud_triangle(PyRendererAgg *self, PyObject *args, PyObjec if (points.dim(0) != 3 || points.dim(1) != 2) { PyErr_Format(PyExc_ValueError, - "points must be a 3x2 array, got %dx%d", + "points must be a 3x2 array, got %" NPY_INTP_FMT "x%" NPY_INTP_FMT, points.dim(0), points.dim(1)); return NULL; } if (colors.dim(0) != 3 || colors.dim(1) != 4) { PyErr_Format(PyExc_ValueError, - "colors must be a 3x4 array, got %dx%d", + "colors must be a 3x4 array, got %" NPY_INTP_FMT "x%" NPY_INTP_FMT, colors.dim(0), colors.dim(1)); return NULL; } @@ -500,21 +500,21 @@ PyRendererAgg_draw_gouraud_triangles(PyRendererAgg *self, PyObject *args, PyObje if (points.size() != 0 && (points.dim(1) != 3 || points.dim(2) != 2)) { PyErr_Format(PyExc_ValueError, - "points must be a Nx3x2 array, got %dx%dx%d", + "points must be a Nx3x2 array, got %" NPY_INTP_FMT "x%" NPY_INTP_FMT "x%" NPY_INTP_FMT, points.dim(0), points.dim(1), points.dim(2)); return NULL; } if (colors.size() != 0 && (colors.dim(1) != 3 || colors.dim(2) != 4)) { PyErr_Format(PyExc_ValueError, - "colors must be a Nx3x4 array, got %dx%dx%d", + "colors must be a Nx3x4 array, got %" NPY_INTP_FMT "x%" NPY_INTP_FMT "x%" NPY_INTP_FMT, colors.dim(0), colors.dim(1), colors.dim(2)); return NULL; } if (points.size() != colors.size()) { PyErr_Format(PyExc_ValueError, - "points and colors arrays must be the same length, got %d and %d", + "points and colors arrays must be the same length, got %" NPY_INTP_FMT " and %" NPY_INTP_FMT, points.dim(0), colors.dim(0)); return NULL; } diff --git a/src/_image_wrapper.cpp b/src/_image_wrapper.cpp index ed7cb50e4a10..5fdd3170154c 100644 --- a/src/_image_wrapper.cpp +++ b/src/_image_wrapper.cpp @@ -273,7 +273,7 @@ image_resample(PyObject *self, PyObject* args, PyObject *kwargs) } else { PyErr_Format( PyExc_ValueError, - "If 3-dimensional, array must be RGBA. Got %d planes.", + "If 3-dimensional, array must be RGBA. Got %" NPY_INTP_FMT " planes.", PyArray_DIM(input_array, 2)); goto error; } diff --git a/src/_path_wrapper.cpp b/src/_path_wrapper.cpp index a18b6bd24634..047e8c5c3107 100644 --- a/src/_path_wrapper.cpp +++ b/src/_path_wrapper.cpp @@ -201,7 +201,7 @@ static PyObject *Py_update_path_extents(PyObject *self, PyObject *args, PyObject if (minpos.dim(0) != 2) { PyErr_Format(PyExc_ValueError, - "minpos must be of length 2, got %d", + "minpos must be of length 2, got %" NPY_INTP_FMT, minpos.dim(0)); return NULL; } diff --git a/src/py_converters.cpp b/src/py_converters.cpp index b4fc84032685..b65e1c844061 100644 --- a/src/py_converters.cpp +++ b/src/py_converters.cpp @@ -537,7 +537,7 @@ int convert_points(PyObject *obj, void *pointsp) if (points->dim(1) != 2) { PyErr_Format(PyExc_ValueError, - "Points must be Nx2 array, got %dx%d", + "Points must be Nx2 array, got %" NPY_INTP_FMT "x%" NPY_INTP_FMT, points->dim(0), points->dim(1)); return 0; } @@ -561,7 +561,7 @@ int convert_transforms(PyObject *obj, void *transp) if (trans->dim(1) != 3 || trans->dim(2) != 3) { PyErr_Format(PyExc_ValueError, - "Transforms must be Nx3x3 array, got %dx%dx%d", + "Transforms must be Nx3x3 array, got %" NPY_INTP_FMT "x%" NPY_INTP_FMT "x%" NPY_INTP_FMT, trans->dim(0), trans->dim(1), trans->dim(2)); return 0; } @@ -585,7 +585,7 @@ int convert_bboxes(PyObject *obj, void *bboxp) if (bbox->dim(1) != 2 || bbox->dim(2) != 2) { PyErr_Format(PyExc_ValueError, - "Bbox array must be Nx2x2 array, got %dx%dx%d", + "Bbox array must be Nx2x2 array, got %" NPY_INTP_FMT "x%" NPY_INTP_FMT "x%" NPY_INTP_FMT, bbox->dim(0), bbox->dim(1), bbox->dim(2)); return 0; } @@ -609,7 +609,7 @@ int convert_colors(PyObject *obj, void *colorsp) if (colors->dim(1) != 4) { PyErr_Format(PyExc_ValueError, - "Colors array must be Nx4 array, got %dx%d", + "Colors array must be Nx4 array, got %" NPY_INTP_FMT "x%" NPY_INTP_FMT, colors->dim(0), colors->dim(1)); return 0; } From 2acf7bd08b705fcfb8897329f69b6d014356ec3c Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 25 Nov 2016 19:43:00 -0500 Subject: [PATCH 6/7] Include Python headers before system headers. This prevents any macro-has-been-redefined warnings. --- src/_gtkagg.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_gtkagg.cpp b/src/_gtkagg.cpp index 0b0f8ef4b0de..f8244b799804 100644 --- a/src/_gtkagg.cpp +++ b/src/_gtkagg.cpp @@ -1,10 +1,10 @@ /* -*- mode: c++; c-basic-offset: 4 -*- */ -#include - #include #include +#include + #include "agg_basics.h" #include "agg_pixfmt_rgba.h" #include "agg_renderer_base.h" From 1ccdfc1aa9814eb09880e86a06a54b8032359bd3 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 26 Nov 2016 00:58:56 -0500 Subject: [PATCH 7/7] Fix NumPy's printf format specifiers in C++. Not sure why it works locally but not on Travis. --- setupext.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setupext.py b/setupext.py index e7d57894660c..d19cdee35237 100644 --- a/setupext.py +++ b/setupext.py @@ -898,6 +898,9 @@ def add_flags(self, ext): ext.define_macros.append(('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')) + # Allow NumPy's printf format specifiers in C++. + ext.define_macros.append(('__STDC_FORMAT_MACROS', 1)) + def get_setup_requires(self): return ['numpy>=1.7.1']