git » libfiu » commit 1be3d9d

python: Remove Python 2 support

author Alberto Bertogli
2023-08-14 11:25:19 UTC
committer Alberto Bertogli
2023-08-14 11:25:19 UTC
parent a417ce4716e1d9d5db4f20fa86d3eea2f3fb2916

python: Remove Python 2 support

Python 2 has been end-of-life for years, remove support so we can reduce
the code complexity and simplify future changes to setup.py.

Makefile +1 -7
bindings/python/fiu_ll.c +2 -15
bindings/python/setup.py +0 -7

diff --git a/Makefile b/Makefile
index 4384b3b..f39896f 100644
--- a/Makefile
+++ b/Makefile
@@ -67,12 +67,6 @@ bindings_install: python3_install
 
 bindings_clean: python_clean
 
-python2: libfiu
-	cd bindings/python && python2 setup.py build
-
-python2_install: python2
-	cd bindings/python && python2 setup.py install
-
 python3: libfiu
 	cd bindings/python && python3 setup.py build
 
@@ -88,7 +82,7 @@ clean: python_clean preload_clean libfiu_clean utils_clean test_clean
 
 .PHONY: default all clean install all_install uninstall all_uninstall \
 	libfiu libfiu_clean libfiu_install libfiu_uninstall \
-	python2 python2_install python3 python3_install python_clean \
+	python3 python3_install python_clean \
 	bindings bindings_install bindings_clean \
 	preload preload_clean preload_install preload_uninstall \
 	utils utils_clean utils_install utils_uninstall \
diff --git a/bindings/python/fiu_ll.c b/bindings/python/fiu_ll.c
index 52c9cd3..7864110 100644
--- a/bindings/python/fiu_ll.c
+++ b/bindings/python/fiu_ll.c
@@ -1,11 +1,10 @@
 
 /*
- * Python 2/3 bindings for libfiu
+ * Python 3 bindings for libfiu
  * Alberto Bertogli (albertito@blitiri.com.ar)
  *
  * This is the low-level module, used by the python one to construct
- * friendlier objects. It support both Python 2 and 3, assuming the constants
- * PYTHON2 and PYTHON3 are defined accordingly.
+ * friendlier objects.
  */
 
 #include <Python.h>
@@ -225,35 +224,23 @@ static PyMethodDef fiu_methods[] = {
 	{ NULL }
 };
 
-#ifdef PYTHON3
 static PyModuleDef fiu_module = {
 	PyModuleDef_HEAD_INIT,
 	.m_name = "libfiu",
 	.m_size = -1,
 	.m_methods = fiu_methods,
 };
-#endif
 
-#ifdef PYTHON2
-PyMODINIT_FUNC initfiu_ll(void)
-#else
 PyMODINIT_FUNC PyInit_fiu_ll(void)
-#endif
 {
 	PyObject *m;
 
-#ifdef PYTHON2
-	m = Py_InitModule("fiu_ll", fiu_methods);
-#else
 	m = PyModule_Create(&fiu_module);
-#endif
 
 	PyModule_AddIntConstant(m, "FIU_ONETIME", FIU_ONETIME);
 
 	fiu_init(0);
 
-#ifdef PYTHON3
 	return m;
-#endif
 }
 
diff --git a/bindings/python/setup.py b/bindings/python/setup.py
index 963f613..0dac6ae 100644
--- a/bindings/python/setup.py
+++ b/bindings/python/setup.py
@@ -5,12 +5,6 @@ import tempfile
 from distutils.core import setup, Extension
 from distutils.command.build_py import build_py
 
-if sys.version_info[0] == 2:
-	ver_define = ('PYTHON2', '1')
-elif sys.version_info[0] == 3:
-	ver_define = ('PYTHON3', '1')
-
-
 # We need to generate the fiu_ctrl.py file from fiu_ctrl.in.py, replacing some
 # environment variables in its contents.
 class generate_and_build_py (build_py):
@@ -39,7 +33,6 @@ class generate_and_build_py (build_py):
 
 fiu_ll = Extension("fiu_ll",
 		sources = ['fiu_ll.c'],
-		define_macros = [ver_define],
 		libraries = ['fiu'],
 
 		# these two allow us to build without having libfiu installed,