File ibus-pinyin-avoid-setup-crash.patch of Package ibus-pinyin.32999
diff -Nura ibus-pinyin-1.5.0/configure ibus-pinyin-1.5.0_new/configure
--- ibus-pinyin-1.5.0/configure 2012-12-18 05:16:36.000000000 +0800
+++ ibus-pinyin-1.5.0_new/configure 2018-11-20 20:17:35.542730466 +0800
@@ -836,6 +836,7 @@
with_gnu_ld
with_sysroot
enable_libtool_lock
+with_python
enable_boost
with_boost
enable_lua_extension
@@ -1512,6 +1513,7 @@
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-sysroot=DIR Search for dependent libraries within DIR
(or the compiler's sysroot if not specified).
+ --with-python=PATH Select python2 or python3
--with-boost=DIR prefix of Boost 1.39 [guess]
Some influential environment variables:
@@ -17550,6 +17552,14 @@
+# Define python version
+
+# Check whether --with-python was given.
+if test "${with_python+set}" = set; then :
+ withval=$with_python; PYTHON=$with_python
+fi
+
+
# check python
@@ -17578,7 +17588,9 @@
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
- as_fn_error $? "too old" "$LINENO" 5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ as_fn_error $? "Python interpreter is too old" "$LINENO" 5
fi
am_display_PYTHON=$PYTHON
else
@@ -17590,7 +17602,7 @@
$as_echo_n "(cached) " >&6
else
- for am_cv_pathless_PYTHON in python python2 python3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do
+ for am_cv_pathless_PYTHON in python python2 python3 python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do
test "$am_cv_pathless_PYTHON" = none && break
prog="import sys
# split strings by '.' and convert to numeric. Append some zeros
@@ -17697,6 +17709,25 @@
PYTHON_PLATFORM=$am_cv_python_platform
+ # Just factor out some code duplication.
+ am_python_setup_sysconfig="\
+import sys
+# Prefer sysconfig over distutils.sysconfig, for better compatibility
+# with python 3.x. See automake bug#10227.
+try:
+ import sysconfig
+except ImportError:
+ can_use_sysconfig = 0
+else:
+ can_use_sysconfig = 1
+# Can't use sysconfig in CPython 2.7, since it's broken in virtualenvs:
+# <https://github.com/pypa/virtualenv/issues/118>
+try:
+ from platform import python_implementation
+ if python_implementation() == 'CPython' and sys.version[:3] == '2.7':
+ can_use_sysconfig = 0
+except ImportError:
+ pass"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON script directory" >&5
@@ -17710,7 +17741,14 @@
else
am_py_prefix=$prefix
fi
- am_cv_python_pythondir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(0,0,prefix='$am_py_prefix'))" 2>/dev/null`
+ am_cv_python_pythondir=`$PYTHON -c "
+$am_python_setup_sysconfig
+if can_use_sysconfig:
+ sitedir = sysconfig.get_path('purelib', vars={'base':'$am_py_prefix'})
+else:
+ from distutils import sysconfig
+ sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix')
+sys.stdout.write(sitedir)"`
case $am_cv_python_pythondir in
$am_py_prefix*)
am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'`
@@ -17747,7 +17785,14 @@
else
am_py_exec_prefix=$exec_prefix
fi
- am_cv_python_pyexecdir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(1,0,prefix='$am_py_exec_prefix'))" 2>/dev/null`
+ am_cv_python_pyexecdir=`$PYTHON -c "
+$am_python_setup_sysconfig
+if can_use_sysconfig:
+ sitedir = sysconfig.get_path('platlib', vars={'platbase':'$am_py_prefix'})
+else:
+ from distutils import sysconfig
+ sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_prefix')
+sys.stdout.write(sitedir)"`
case $am_cv_python_pyexecdir in
$am_py_exec_prefix*)
am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'`
@@ -21674,6 +21719,7 @@
Version $VERSION
Install prefix $prefix
Use boost $enable_boost
+ python $PYTHON
Build lua extension $enable_lua_extension
Build english input mode $enable_english_input_mode
" >&5
@@ -21682,6 +21728,7 @@
Version $VERSION
Install prefix $prefix
Use boost $enable_boost
+ python $PYTHON
Build lua extension $enable_lua_extension
Build english input mode $enable_english_input_mode
" >&6; }
diff -Nura ibus-pinyin-1.5.0/configure.ac ibus-pinyin-1.5.0_new/configure.ac
--- ibus-pinyin-1.5.0/configure.ac 2012-12-18 05:16:30.000000000 +0800
+++ ibus-pinyin-1.5.0_new/configure.ac 2018-11-20 20:19:05.450483852 +0800
@@ -81,6 +81,13 @@
AC_PATH_PROG(ENV, env)
AC_SUBST(ENV)
+# Define python version
+AC_ARG_WITH(python,
+ AS_HELP_STRING([--with-python[=PATH]],
+ [Select python2 or python3]),
+ [PYTHON=$with_python], []
+)
+
# check python
AM_PATH_PYTHON([2.5])
@@ -166,6 +173,7 @@
Version $VERSION
Install prefix $prefix
Use boost $enable_boost
+ python $PYTHON
Build lua extension $enable_lua_extension
Build english input mode $enable_english_input_mode
])
diff -Nura ibus-pinyin-1.5.0/setup/ibus-setup-pinyin.in ibus-pinyin-1.5.0_new/setup/ibus-setup-pinyin.in
--- ibus-pinyin-1.5.0/setup/ibus-setup-pinyin.in 2012-07-09 22:32:10.000000000 +0800
+++ ibus-pinyin-1.5.0_new/setup/ibus-setup-pinyin.in 2018-11-20 20:19:05.450483852 +0800
@@ -26,5 +26,4 @@
export IBUS_DATAROOTDIR=@datarootdir@
export IBUS_LOCALEDIR=@localedir@
cd @prefix@/share/ibus-pinyin/setup/
-exec python main.py $@
-
+exec @PYTHON@ main.py $@
diff -Nura ibus-pinyin-1.5.0/setup/main.py ibus-pinyin-1.5.0_new/setup/main.py
--- ibus-pinyin-1.5.0/setup/main.py 2012-07-09 22:32:10.000000000 +0800
+++ ibus-pinyin-1.5.0_new/setup/main.py 2018-11-20 20:19:05.450483852 +0800
@@ -20,15 +20,21 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+from __future__ import print_function
+
import gettext
import locale
import os
import sys
+from gi import require_version as gi_require_version
+gi_require_version('GLib', '2.0')
+gi_require_version('Gtk', '3.0')
+gi_require_version('IBus', '1.0')
+
from gi.repository import GLib
from gi.repository import Gtk
from gi.repository import IBus
-from xdg import BaseDirectory
import version
@@ -250,6 +256,8 @@
def __correct_pinyin_toggled_cb(widget):
val = widget.get_active()
+ for w in self.__correct_pinyin_widgets:
+ self.__builder.get_object(w[0]).set_sensitive(val)
map(lambda w: self.__builder.get_object(w[0]).set_sensitive(val),
self.__correct_pinyin_widgets)
self.__correct_pinyin.connect("toggled", __correct_pinyin_toggled_cb)
@@ -300,8 +308,8 @@
def __fuzzy_pinyin_toggled_cb(widget):
val = widget.get_active()
- map(lambda w: self.__builder.get_object(w[0]).set_sensitive(val),
- self.__fuzzy_pinyin_widgets)
+ for w in self.__fuzzy_pinyin_widgets:
+ self.__builder.get_object(w[0]).set_sensitive(val)
self.__fuzzy_pinyin.connect("toggled", __fuzzy_pinyin_toggled_cb)
# init value
@@ -404,7 +412,7 @@
elif isinstance(val, str):
var = GLib.Variant.new_string(val)
else:
- print >> sys.stderr, "val(%s) is not in support type." % repr(val)
+ print("val(%s) is not in support type." % repr(val), file=sys.stderr)
return
self.__values[name] = val