From 10e961b031eab8f49a3d6edfd27967cce0031dd0 Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Tue, 20 Apr 2021 14:47:44 +0530 Subject: [PATCH 1/6] CLN : Remove support for Python 2 and remove python 3-only or 2-only conditionals and __future__ imports modified: kiva/agg/src/agg_std_string.i modified: kiva/agg/src/agg_typemaps.i modified: kiva/agg/src/win32/plat_support.i modified: kiva/gl/__init__.py modified: kiva/gl/src/swig/agg_std_string.i modified: kiva/quartz/ABCGI.pyx modified: kiva/quartz/CTFont.pyx --- kiva/agg/src/agg_std_string.i | 2 -- kiva/agg/src/agg_typemaps.i | 8 -------- kiva/agg/src/win32/plat_support.i | 4 ---- kiva/gl/__init__.py | 2 -- kiva/gl/src/swig/agg_std_string.i | 2 -- kiva/quartz/ABCGI.pyx | 2 -- kiva/quartz/CTFont.pyx | 2 -- 7 files changed, 22 deletions(-) diff --git a/kiva/agg/src/agg_std_string.i b/kiva/agg/src/agg_std_string.i index 416f271e7..458f5d033 100644 --- a/kiva/agg/src/agg_std_string.i +++ b/kiva/agg/src/agg_std_string.i @@ -18,12 +18,10 @@ { $1 = new std::string((char *)PyBytes_AsString($input)); } -#if PY_VERSION_HEX >= 0x03030000 else if (PyUnicode_Check($input)) { $1 = new std::string((char *)PyUnicode_AsUTF8($input)); } -#endif else { PyErr_SetString (PyExc_TypeError, "not a String"); diff --git a/kiva/agg/src/agg_typemaps.i b/kiva/agg/src/agg_typemaps.i index 4efb4a3a9..ca0a948c7 100644 --- a/kiva/agg/src/agg_typemaps.i +++ b/kiva/agg/src/agg_typemaps.i @@ -353,18 +353,10 @@ { $1 = (char *)PyBytes_AsString($input); } -#if PY_VERSION_HEX >= 0x03030000 else if (PyUnicode_Check($input)) { $1 = (char *)PyUnicode_AsUTF8($input); } -#elif PY_VERSION_HEX < 0x03000000 - else if (PyUnicode_Check($input)) - { - utfstr = PyUnicode_AsUTF8String($input); - $1 = (char *)PyString_AsString(utfstr); - } -#endif else { PyErr_SetString(PyExc_TypeError, "not a string"); diff --git a/kiva/agg/src/win32/plat_support.i b/kiva/agg/src/win32/plat_support.i index ce2ce8a18..46c89550c 100644 --- a/kiva/agg/src/win32/plat_support.i +++ b/kiva/agg/src/win32/plat_support.i @@ -61,11 +61,7 @@ namespace agg24 // unsigned value. It is cleared at the end of this file. %typemap(in) unsigned { -%#if PY_VERSION_HEX < 0x03000000 - PyObject* obj = PyNumber_Int($input); -%#else PyObject* obj = PyNumber_Long($input); -%#endif if (PyErr_Occurred()) SWIG_fail; $1 = (unsigned) PyLong_AsLong(obj); if (PyErr_Occurred()) SWIG_fail; diff --git a/kiva/gl/__init__.py b/kiva/gl/__init__.py index 380d82fd9..89ff620f8 100644 --- a/kiva/gl/__init__.py +++ b/kiva/gl/__init__.py @@ -7,8 +7,6 @@ # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! -from __future__ import absolute_import, print_function - import ctypes from math import floor import sys diff --git a/kiva/gl/src/swig/agg_std_string.i b/kiva/gl/src/swig/agg_std_string.i index fb5de06c0..0f31551c8 100644 --- a/kiva/gl/src/swig/agg_std_string.i +++ b/kiva/gl/src/swig/agg_std_string.i @@ -19,12 +19,10 @@ { $1 = new std::string((char *)PyBytes_AsString($input)); } -#if PY_VERSION_HEX >= 0x03030000 else if (PyUnicode_Check($input)) { $1 = new std::string((char *)PyUnicode_AsUTF8($input)); } -#endif else { PyErr_SetString (PyExc_TypeError, "not a String"); diff --git a/kiva/quartz/ABCGI.pyx b/kiva/quartz/ABCGI.pyx index 2351acaa0..d434c0628 100644 --- a/kiva/quartz/ABCGI.pyx +++ b/kiva/quartz/ABCGI.pyx @@ -7,8 +7,6 @@ # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! -from __future__ import print_function - include "Python.pxi" include "CoreFoundation.pxi" include "CoreGraphics.pxi" diff --git a/kiva/quartz/CTFont.pyx b/kiva/quartz/CTFont.pyx index 5d2eff319..b62b8aa61 100644 --- a/kiva/quartz/CTFont.pyx +++ b/kiva/quartz/CTFont.pyx @@ -7,8 +7,6 @@ # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! -from __future__ import print_function - include "CoreFoundation.pxi" include "CoreGraphics.pxi" include "CoreText.pxi" From 6eac8ee3ddf7b679241534e6c8b795da8aaf05e1 Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Tue, 20 Apr 2021 15:46:15 +0530 Subject: [PATCH 2/6] FIX : Set language level on cython file modified: kiva/quartz/ABCGI.pyx modified: kiva/quartz/CTFont.pyx --- kiva/quartz/ABCGI.pyx | 1 + kiva/quartz/CTFont.pyx | 1 + 2 files changed, 2 insertions(+) diff --git a/kiva/quartz/ABCGI.pyx b/kiva/quartz/ABCGI.pyx index d434c0628..2afdd7811 100644 --- a/kiva/quartz/ABCGI.pyx +++ b/kiva/quartz/ABCGI.pyx @@ -1,3 +1,4 @@ +# cython: language_level=3 # (C) Copyright 2004-2021 Enthought, Inc., Austin, TX # All rights reserved. # diff --git a/kiva/quartz/CTFont.pyx b/kiva/quartz/CTFont.pyx index b62b8aa61..f7659391f 100644 --- a/kiva/quartz/CTFont.pyx +++ b/kiva/quartz/CTFont.pyx @@ -1,3 +1,4 @@ +# cython: language_level=3 # (C) Copyright 2004-2021 Enthought, Inc., Austin, TX # All rights reserved. # From ab2a7991ed84236ac5923ba61aaac17bd4e3c62d Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Tue, 20 Apr 2021 16:13:27 +0530 Subject: [PATCH 3/6] FIX : Set the language level cython directive correctly modified: kiva/quartz/ABCGI.pyx modified: kiva/quartz/CTFont.pyx modified: setup.py --- kiva/quartz/ABCGI.pyx | 1 - kiva/quartz/CTFont.pyx | 1 - setup.py | 5 ++++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/kiva/quartz/ABCGI.pyx b/kiva/quartz/ABCGI.pyx index 2afdd7811..d434c0628 100644 --- a/kiva/quartz/ABCGI.pyx +++ b/kiva/quartz/ABCGI.pyx @@ -1,4 +1,3 @@ -# cython: language_level=3 # (C) Copyright 2004-2021 Enthought, Inc., Austin, TX # All rights reserved. # diff --git a/kiva/quartz/CTFont.pyx b/kiva/quartz/CTFont.pyx index f7659391f..b62b8aa61 100644 --- a/kiva/quartz/CTFont.pyx +++ b/kiva/quartz/CTFont.pyx @@ -1,4 +1,3 @@ -# cython: language_level=3 # (C) Copyright 2004-2021 Enthought, Inc., Austin, TX # All rights reserved. # diff --git a/setup.py b/setup.py index 16a6b3feb..31591f33d 100644 --- a/setup.py +++ b/setup.py @@ -388,7 +388,7 @@ def macos_extensions(): for framework in frameworks: extra_link_args.extend(['-framework', framework]) - return[ + extensions = [ Extension( 'kiva.quartz.ABCGI', sources=[ @@ -426,6 +426,9 @@ def macos_extensions(): include_dirs=include_dirs, ) ] + for ext in extensions: + ext.cython_directives = {"language_level": 3} + return extensions if __name__ == "__main__": From d46fe0692fd26fb3b87b8d9e5d92c9ee754445ef Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Tue, 20 Apr 2021 16:14:26 +0530 Subject: [PATCH 4/6] DOC : Add minor comment regd language level cython directive modified: setup.py --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index 31591f33d..647b1ebb3 100644 --- a/setup.py +++ b/setup.py @@ -426,6 +426,8 @@ def macos_extensions(): include_dirs=include_dirs, ) ] + # The language level is 2 by default and until it becomes 3, we need to + # explicitly set the cython_directives on the extensions. for ext in extensions: ext.cython_directives = {"language_level": 3} return extensions From 50f6ebdba6fd02694b0ebdf695a450978358fbd5 Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Tue, 20 Apr 2021 16:33:03 +0530 Subject: [PATCH 5/6] CLN : Undo some of the changes remove changes to setup and __future__ imports modified: kiva/quartz/ABCGI.pyx modified: kiva/quartz/CTFont.pyx modified: setup.py --- kiva/quartz/ABCGI.pyx | 2 ++ kiva/quartz/CTFont.pyx | 2 ++ setup.py | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/kiva/quartz/ABCGI.pyx b/kiva/quartz/ABCGI.pyx index d434c0628..2351acaa0 100644 --- a/kiva/quartz/ABCGI.pyx +++ b/kiva/quartz/ABCGI.pyx @@ -7,6 +7,8 @@ # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! +from __future__ import print_function + include "Python.pxi" include "CoreFoundation.pxi" include "CoreGraphics.pxi" diff --git a/kiva/quartz/CTFont.pyx b/kiva/quartz/CTFont.pyx index b62b8aa61..5d2eff319 100644 --- a/kiva/quartz/CTFont.pyx +++ b/kiva/quartz/CTFont.pyx @@ -7,6 +7,8 @@ # is also available online at http://www.enthought.com/licenses/BSD.txt # # Thanks for using Enthought open source! +from __future__ import print_function + include "CoreFoundation.pxi" include "CoreGraphics.pxi" include "CoreText.pxi" diff --git a/setup.py b/setup.py index 647b1ebb3..5a2c4e826 100644 --- a/setup.py +++ b/setup.py @@ -388,7 +388,7 @@ def macos_extensions(): for framework in frameworks: extra_link_args.extend(['-framework', framework]) - extensions = [ + return [ Extension( 'kiva.quartz.ABCGI', sources=[ From f782becc22d13b76032fe44f33e240df8506c111 Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Tue, 20 Apr 2021 16:34:05 +0530 Subject: [PATCH 6/6] FIX : undo changes to setup modified: setup.py --- setup.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/setup.py b/setup.py index 5a2c4e826..13ca829f8 100644 --- a/setup.py +++ b/setup.py @@ -426,11 +426,6 @@ def macos_extensions(): include_dirs=include_dirs, ) ] - # The language level is 2 by default and until it becomes 3, we need to - # explicitly set the cython_directives on the extensions. - for ext in extensions: - ext.cython_directives = {"language_level": 3} - return extensions if __name__ == "__main__":