Package: python-pyperclip Version: 1.5.32-1 Severity: normal Tags: patch User: ubuntu-de...@lists.ubuntu.com Usertags: origin-ubuntu bionic ubuntu-patch
Dear Maintainer, In Ubuntu, the attached patch was applied to achieve the following: * d/p/move-to-gtk3.patch: Use GTK+3 instead of GTK+2 (LP: #1722553). Thanks for considering the patch. -- System Information: Debian Release: buster/sid APT prefers bionic APT policy: (500, 'bionic'), (500, 'artful-updates') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 4.13.0-19-generic (SMP w/4 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system)
diff -Nru python-pyperclip-1.5.32/debian/control python-pyperclip-1.5.32/debian/control --- python-pyperclip-1.5.32/debian/control 2017-11-03 03:05:14.000000000 -0400 +++ python-pyperclip-1.5.32/debian/control 2017-12-19 16:25:22.000000000 -0500 @@ -13,7 +13,7 @@ Package: python-pyperclip Architecture: all -Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, xclip | xsel | python-gtk2 | python-qt4 +Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, xclip | xsel | python-gi | python-qt4 Description: Cross-platform clipboard module for Python This module is a cross-platform Python module for copy and paste clipboard functions. @@ -22,7 +22,7 @@ Package: python3-pyperclip Architecture: all -Depends: ${shlibs:Depends}, ${misc:Depends}, ${python3:Depends}, xclip | xsel | python3-pyqt4 +Depends: ${shlibs:Depends}, ${misc:Depends}, ${python3:Depends}, xclip | xsel | python3-gi | python3-pyqt4 Description: Cross-platform clipboard module for Python3 This module is a cross-platform Python3 module for copy and paste clipboard functions. diff -Nru python-pyperclip-1.5.32/debian/patches/move-to-gtk3.patch python-pyperclip-1.5.32/debian/patches/move-to-gtk3.patch --- python-pyperclip-1.5.32/debian/patches/move-to-gtk3.patch 1969-12-31 19:00:00.000000000 -0500 +++ python-pyperclip-1.5.32/debian/patches/move-to-gtk3.patch 2017-12-19 16:25:22.000000000 -0500 @@ -0,0 +1,97 @@ +Description: Switch from GTK+2 to GTK+3 to avoid import of mutually exclusive + modules that resulted in the following error: + AttributeError: When using gi.repository you must not import static modules like + "gobject". Please change all occurrences of "import gobject" to + "from gi.repository import GObject". See: + https://bugzilla.gnome.org/show_bug.cgi?id=709183 +Author: Corey Bryant <corey.bry...@canonical.com> +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1722553 +Origin: https://github.com/asweigart/pyperclip/pull/111 +Forwarded: yes + +--- a/pyperclip/__init__.py ++++ b/pyperclip/__init__.py +@@ -20,12 +20,13 @@ + sudo apt-get install xclip + sudo apt-get install xsel + +-Otherwise on Linux, you will need the gtk or PyQt5/PyQt4 modules installed. ++Otherwise on Linux, you will need the gi (GTK+ 3) or PyQt5/PyQt4 modules installed. ++gtk (GTK +2) is still supported as an older alternative to gi. + + gtk and PyQt4 modules are not available for Python 3, + and this module does not work with PyGObject yet. + +-Note: There seem sto be a way to get gtk on Python 3, according to: ++Note: There seems to be a way to get gtk on Python 3, according to: + https://askubuntu.com/questions/697397/python3-is-not-supporting-gtk-module + + Cygwin is currently not supported. +@@ -104,11 +105,18 @@ + # Setup for the LINUX platform: + if HAS_DISPLAY: + try: +- import gtk # check if gtk is installed ++ import gi # check if gi is installed (for GTK+ 3) + except ImportError: +- pass # We want to fail fast for all non-ImportError exceptions. ++ try: ++ import gtk # check if gtk is installed (fallback to GTK+ 2) ++ except ImportError: ++ pass # We want to fail fast for all non-ImportError exceptions. ++ else: ++ return init_gtk_clipboard() + else: +- return init_gtk_clipboard() ++ if gi.version_info[0] >= 3: ++ return init_gi_clipboard() ++ pass + + if _executable_exists("xclip"): + return init_xclip_clipboard() +@@ -161,6 +169,7 @@ + clipboard_types = {'pbcopy': init_osx_pbcopy_clipboard, + 'pyobjc': init_osx_pyobjc_clipboard, + 'gtk': init_gtk_clipboard, ++ 'gi': init_gi_clipboard, + 'qt': init_qt_clipboard, # TODO - split this into 'qtpy', 'pyqt4', and 'pyqt5' + 'xclip': init_xclip_clipboard, + 'xsel': init_xsel_clipboard, +--- a/pyperclip/clipboards.py ++++ b/pyperclip/clipboards.py +@@ -57,7 +57,6 @@ + import gtk + + def copy_gtk(text): +- global cb + cb = gtk.Clipboard() + cb.set_text(text) + cb.store() +@@ -73,6 +72,27 @@ + return copy_gtk, paste_gtk + + ++def init_gi_clipboard(): ++ import gi ++ gi.require_version('Gtk', '3.0') ++ from gi.repository import Gtk, Gdk ++ cb = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) ++ ++ def copy_gi(text): ++ cb.set_text(text, -1) ++ cb.store() ++ ++ def paste_gi(): ++ clipboardContents = cb.wait_for_text() ++ # for python 2, returns None if the clipboard is blank. ++ if clipboardContents is None: ++ return '' ++ else: ++ return clipboardContents ++ ++ return copy_gi, paste_gi ++ ++ + def init_qt_clipboard(): + # $DISPLAY should exist + diff -Nru python-pyperclip-1.5.32/debian/patches/series python-pyperclip-1.5.32/debian/patches/series --- python-pyperclip-1.5.32/debian/patches/series 1969-12-31 19:00:00.000000000 -0500 +++ python-pyperclip-1.5.32/debian/patches/series 2017-12-19 16:25:22.000000000 -0500 @@ -0,0 +1 @@ +move-to-gtk3.patch