[pygobject] setup.py: always define PY_SSIZE_T_CLEAN. Fixes #185



commit b39e17e9d22659a9538ffeb14b2a6e8a6397887f
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Fri Mar 23 07:07:26 2018 +0100

    setup.py: always define PY_SSIZE_T_CLEAN. Fixes #185
    
    Including the Python headers with it results in a lot of
    -Wredundant-decls, so disable that warning.

 gi/pyglib-python-compat.h | 4 ++++
 setup.py                  | 8 +++-----
 2 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/gi/pyglib-python-compat.h b/gi/pyglib-python-compat.h
index 8b4ac400..cf0ebb4e 100644
--- a/gi/pyglib-python-compat.h
+++ b/gi/pyglib-python-compat.h
@@ -19,6 +19,10 @@
 #ifndef __PYGLIB_PYTHON_COMPAT_H__
 #define __PYGLIB_PYTHON_COMPAT_H__
 
+#ifndef PY_SSIZE_T_CLEAN
+#error "PY_SSIZE_T_CLEAN not defined"
+#endif
+
 #include <Python.h>
 
 # define PYGLIB_CPointer_Check PyCapsule_CheckExact
diff --git a/setup.py b/setup.py
index ce257e14..249d9e6d 100755
--- a/setup.py
+++ b/setup.py
@@ -24,7 +24,6 @@ import errno
 import subprocess
 import tarfile
 import sysconfig
-import platform
 from email import parser
 
 import pkg_resources
@@ -484,6 +483,7 @@ class build_tests(Command):
                 os.path.join(tests_dir, "test-unknown.h"),
                 os.path.join(tests_dir, "test-floating.h"),
             ],
+            define_macros=[("PY_SSIZE_T_CLEAN", None)],
         )
         add_ext_pkg_config_dep(ext, compiler.compiler_type, "glib-2.0")
         add_ext_pkg_config_dep(ext, compiler.compiler_type, "gio-2.0")
@@ -750,7 +750,6 @@ def add_ext_warn_flags(ext, compiler, _cache={}):
             "-Wold-style-definition",
             "-Wpacked",
             "-Wpointer-arith",
-            "-Wredundant-decls",
             "-Wrestrict",
             "-Wreturn-type",
             "-Wshadow",
@@ -779,9 +778,6 @@ def add_ext_warn_flags(ext, compiler, _cache={}):
             "-fno-strict-aliasing",
         ]
 
-        if platform.python_implementation() == "PyPy":
-            args.append("-Wno-redundant-decls")
-
         _cache[cache_key] = filter_compiler_arguments(compiler, args)
 
     ext.extra_compile_args += _cache[cache_key]
@@ -951,12 +947,14 @@ def main():
         name='gi._gi',
         sources=sources,
         include_dirs=[script_dir, gi_dir],
+        define_macros=[("PY_SSIZE_T_CLEAN", None)],
     )
 
     gi_cairo_ext = Extension(
         name='gi._gi_cairo',
         sources=cairo_sources,
         include_dirs=[script_dir, gi_dir],
+        define_macros=[("PY_SSIZE_T_CLEAN", None)],
     )
 
     setup(


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]