[gnome-commander] Support for python >= 3.x
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Support for python >= 3.x
- Date: Sun, 19 Feb 2017 09:40:14 +0000 (UTC)
commit e5e653471725361e035dceaed71e095bece0705b
Author: Uwe Scholz <uwescholz src gnome org>
Date: Fri Feb 17 22:46:25 2017 +0100
Support for python >= 3.x
Also, in configure.ac and python.m4, the checks for python includes and
cflags are simplified by the help of python-config.
configure.ac | 17 +++++------------
m4/python.m4 | 7 +------
src/gnome-cmd-python-plugin.cc | 13 +++++++++++++
3 files changed, 19 insertions(+), 18 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9a5b1c2..67679a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -228,18 +228,12 @@ fi
if test "x$have_python" != "xno"; then
PY_PREFIX=`$PYTHON -c 'import sys ; print(sys.prefix)'`
PY_EXEC_PREFIX=`$PYTHON -c 'import sys ; print(sys.exec_prefix)'`
- PYTHON_LIBS="-lpython$PYTHON_VERSION"
- PYTHON_LIB_LOC="-L$PY_EXEC_PREFIX/lib/python$PYTHON_VERSION/config"
- PYTHON_CFLAGS="-I$PY_PREFIX/include/python$PYTHON_VERSION"
- PYTHON_MAKEFILE="$PY_EXEC_PREFIX/lib/python$PYTHON_VERSION/config/Makefile"
- PYTHON_LOCALMODLIBS=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $PYTHON_MAKEFILE`
- PYTHON_BASEMODLIBS=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $PYTHON_MAKEFILE`
- PYTHON_OTHER_LIBS=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $PYTHON_MAKEFILE`
- PYTHON_EXTRA_LIBS="$PYTHON_LOCALMODLIBS $PYTHON_BASEMODLIBS $PYTHON_OTHER_LIBS"
+ dnl PYTHON_LIBS="-lpython$PYTHON_VERSION"
+ PYTHON_LIBS=`$PYTHON-config --ldflags`
+ dnl PYTHON_CFLAGS="-I$PY_PREFIX/include/python$PYTHON_VERSION"
+ PYTHON_CFLAGS=`$PYTHON-config --cflags`
AC_SUBST([PYTHON_LIBS])
- AC_SUBST([PYTHON_LIB_LOC])
AC_SUBST([PYTHON_CFLAGS])
- AC_SUBST([PYTHON_EXTRA_LIBS])
dnl FIXME: do we really need this test?
AC_MSG_CHECKING([whether we can build a shared library depending on libpython])
@@ -254,7 +248,7 @@ Py_Exit (0);
}
EOF
- if ${CC} $PYTHON_CFLAGS $PYTHON_LIBS $PYTHON_EXTRA_LIBS -fPIC -shared -o testpython.so testpython.c
-Wl,-soname,testpython.so >/dev/null 2>&1 && \
+ if ${CC} $PYTHON_CFLAGS $PYTHON_LIBS -fPIC -shared -o testpython.so testpython.c
-Wl,-soname,testpython.so >/dev/null 2>&1 && \
( objdump --headers --private-headers testpython.so | grep 'testpython' ) >/dev/null 2>&1; then
result=yes
else
@@ -374,7 +368,6 @@ echo " LDFLAGS : ${LDFLAGS}"
echo ""
echo " Python plugins support: ${enable_python}"
echo ""
-echo ""
echo "Optional file metadata support:"
echo ""
echo " Exif support : ${have_exiv2}"
diff --git a/m4/python.m4 b/m4/python.m4
index 533d2f8..d03b2a9 100644
--- a/m4/python.m4
+++ b/m4/python.m4
@@ -43,12 +43,7 @@ AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
[AC_REQUIRE([AM_PATH_PYTHON])
AC_MSG_CHECKING(for headers required to compile python extensions)
dnl deduce PYTHON_INCLUDES
-py_prefix=`$PYTHON -c "import sys; print(sys.prefix)"`
-py_exec_prefix=`$PYTHON -c "import sys; print(sys.exec_prefix)"`
-PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
-if test "$py_prefix" != "$py_exec_prefix"; then
- PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
-fi
+PYTHON_INCLUDES=`$PYTHON-config --includes`
AC_SUBST(PYTHON_INCLUDES)
dnl check if the headers exist:
save_CPPFLAGS="$CPPFLAGS"
diff --git a/src/gnome-cmd-python-plugin.cc b/src/gnome-cmd-python-plugin.cc
index a308f99..d666f20 100644
--- a/src/gnome-cmd-python-plugin.cc
+++ b/src/gnome-cmd-python-plugin.cc
@@ -222,7 +222,11 @@ gboolean gnome_cmd_python_plugin_execute(const PythonPluginData *plugin, GnomeCm
if (!pURIclass)
goto out_B;
+#if PY_MAJOR_VERSION > 2
+ pName = PyUnicode_FromString(plugin->fname);
+#else
pName = PyString_FromString(plugin->fname);
+#endif
pModule = PyImport_Import(pName);
Py_XDECREF(pName);
@@ -287,8 +291,13 @@ gboolean gnome_cmd_python_plugin_execute(const PythonPluginData *plugin, GnomeCm
main_win_xid = GDK_WINDOW_XID (GTK_WIDGET (mw)->window);
pMainWinXID = PyLong_FromUnsignedLong (main_win_xid);
+#if PY_MAJOR_VERSION > 2
+ pActiveCwd = PyUnicode_FromString(active_dir);
+ pInactiveCwd = PyUnicode_FromString(inactive_dir);
+#else
pActiveCwd = PyString_FromString (active_dir);
pInactiveCwd = PyString_FromString (inactive_dir);
+#endif
pSelectedFiles = PyTuple_New(n);
DEBUG('p', "Main window XID: %lu (%#lx)\n", main_win_xid, main_win_xid);
@@ -319,7 +328,11 @@ gboolean gnome_cmd_python_plugin_execute(const PythonPluginData *plugin, GnomeCm
if (pValue)
{
+#if PY_MAJOR_VERSION > 2
+ retval = PyLong_AsLong(pValue);
+#else
retval = PyInt_AsLong(pValue);
+#endif
DEBUG('p', "Result of call %s." MODULE_INIT_FUNC "(): %ld\n", plugin->fname, retval);
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]