From f291383b3fda37faf8aa5d786154191e84c2fa42 Mon Sep 17 00:00:00 2001 From: chuanzhu xu Date: Fri, 31 May 2019 08:10:08 -0400 Subject: [PATCH 1/4] remove outdated gtk package from code --- doc/source/install.rst | 1 - doc/source/user_guide/io.rst | 2 +- doc/source/whatsnew/v0.25.0.rst | 2 +- pandas/core/generic.py | 2 +- pandas/io/clipboard/__init__.py | 20 +++++--------------- pandas/io/clipboard/clipboards.py | 16 ---------------- pandas/io/clipboards.py | 2 +- 7 files changed, 9 insertions(+), 36 deletions(-) diff --git a/doc/source/install.rst b/doc/source/install.rst index b3b5945cc515e..98443ede2e965 100644 --- a/doc/source/install.rst +++ b/doc/source/install.rst @@ -281,7 +281,6 @@ Optional Dependencies `qtpy `__ (requires PyQt or PySide), `PyQt5 `__, `PyQt4 `__, - `pygtk `__, `xsel `__, or `xclip `__: necessary to use :func:`~pandas.read_clipboard`. Most package managers on Linux distributions will have ``xclip`` and/or ``xsel`` immediately available for installation. diff --git a/doc/source/user_guide/io.rst b/doc/source/user_guide/io.rst index 9ec39c0ff2b23..61ed604db74bd 100644 --- a/doc/source/user_guide/io.rst +++ b/doc/source/user_guide/io.rst @@ -3253,7 +3253,7 @@ We can see that we got the same content back, which we had earlier written to th .. note:: - You may need to install xclip or xsel (with gtk, PyQt5, PyQt4 or qtpy) on Linux to use these methods. + You may need to install xclip or xsel (with PyQt5, PyQt4 or qtpy) on Linux to use these methods. .. _io.pickle: diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index a65b92737c220..a020847c365ad 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -428,7 +428,7 @@ Other ^^^^^ - Removed unused C functions from vendored UltraJSON implementation (:issue:`26198`) - +- Removed outdated packge gtk import for clipboard related (:issue:`26563`) .. _whatsnew_0.250.contributors: diff --git a/pandas/core/generic.py b/pandas/core/generic.py index debffb80dde27..3dc77264c64b4 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -2647,7 +2647,7 @@ def to_clipboard(self, excel=True, sep=None, **kwargs): ----- Requirements for your platform. - - Linux : `xclip`, or `xsel` (with `gtk` or `PyQt4` modules) + - Linux : `xclip`, or `xsel` (with `PyQt4` modules) - Windows : none - OS X : none diff --git a/pandas/io/clipboard/__init__.py b/pandas/io/clipboard/__init__.py index b76a843e3e7f2..573f238479c95 100644 --- a/pandas/io/clipboard/__init__.py +++ b/pandas/io/clipboard/__init__.py @@ -18,10 +18,10 @@ On Linux, install xclip or xsel via package manager. For example, in Debian: sudo apt-get install xclip -Otherwise on Linux, you will need the gtk, qtpy or PyQt modules installed. +Otherwise on Linux, you will need the qtpy or PyQt modules installed. qtpy also requires a python-qt-bindings module: PyQt4, PyQt5, PySide, PySide2 -gtk and PyQt4 modules are not available for Python 3, +PyQt4 modules are not available for Python 3, and this module does not work with PyGObject yet. """ __version__ = '1.5.27' @@ -29,10 +29,9 @@ import platform import os import subprocess -from .clipboards import (init_osx_clipboard, - init_gtk_clipboard, init_qt_clipboard, - init_xclip_clipboard, init_xsel_clipboard, - init_klipper_clipboard, init_no_clipboard) +from .clipboards import ( + init_osx_clipboard, init_qt_clipboard, init_xclip_clipboard, + init_xsel_clipboard, init_klipper_clipboard, init_no_clipboard) from .windows import init_windows_clipboard # `import qtpy` sys.exit()s if DISPLAY is not in the environment. @@ -60,14 +59,6 @@ def determine_clipboard(): return init_osx_clipboard() if HAS_DISPLAY: # Determine which command/module is installed, if any. - try: - # Check if gtk is installed - import gtk # noqa - except ImportError: - pass - else: - return init_gtk_clipboard() - try: # qtpy is a small abstraction layer that lets you write # applications using a single api call to either PyQt or PySide @@ -104,7 +95,6 @@ def set_clipboard(clipboard): global copy, paste clipboard_types = {'osx': init_osx_clipboard, - 'gtk': init_gtk_clipboard, 'qt': init_qt_clipboard, 'xclip': init_xclip_clipboard, 'xsel': init_xsel_clipboard, diff --git a/pandas/io/clipboard/clipboards.py b/pandas/io/clipboard/clipboards.py index 66e2e35bf0c59..52abdeafb5ecc 100644 --- a/pandas/io/clipboard/clipboards.py +++ b/pandas/io/clipboard/clipboards.py @@ -22,22 +22,6 @@ def paste_osx(): return copy_osx, paste_osx -def init_gtk_clipboard(): - import gtk - - def copy_gtk(text): - global cb - cb = gtk.Clipboard() - cb.set_text(text) - cb.store() - - def paste_gtk(): - clipboardContents = gtk.Clipboard().wait_for_text() - return clipboardContents - - return copy_gtk, paste_gtk - - def init_qt_clipboard(): # $DISPLAY should exist diff --git a/pandas/io/clipboards.py b/pandas/io/clipboards.py index be1256edf7afe..dc30285895dd5 100644 --- a/pandas/io/clipboards.py +++ b/pandas/io/clipboards.py @@ -91,7 +91,7 @@ def to_clipboard(obj, excel=True, sep=None, **kwargs): # pragma: no cover Notes ----- Requirements for your platform - - Linux: xclip, or xsel (with gtk or PyQt4 modules) + - Linux: xclip, or xsel (with PyQt4 modules) - Windows: - OS X: """ From 141dd47c7248a96562d0402ba6ad4cb6efbf2e04 Mon Sep 17 00:00:00 2001 From: chuanzhu xu Date: Fri, 31 May 2019 18:23:07 -0400 Subject: [PATCH 2/4] remove whatsnew changes --- doc/source/whatsnew/v0.25.0.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index d0dcbafebd216..89a9da4a73b35 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -598,7 +598,6 @@ Other - Removed unused C functions from vendored UltraJSON implementation (:issue:`26198`) - Bug in :func:`factorize` when passing an ``ExtensionArray`` with a custom ``na_sentinel`` (:issue:`25696`). - Allow :class:`Index` and :class:`RangeIndex` to be passed to numpy ``min`` and ``max`` functions. -- Removed outdated packge gtk import for clipboard related (:issue:`26563`) .. _whatsnew_0.250.contributors: From b4061f804690444e48ba77dee75ca771cd395241 Mon Sep 17 00:00:00 2001 From: chuanzhu xu Date: Fri, 31 May 2019 18:26:49 -0400 Subject: [PATCH 3/4] update comment about PyQt4, since it support python 3 --- pandas/io/clipboard/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/io/clipboard/__init__.py b/pandas/io/clipboard/__init__.py index 573f238479c95..2063978c76c5a 100644 --- a/pandas/io/clipboard/__init__.py +++ b/pandas/io/clipboard/__init__.py @@ -21,8 +21,7 @@ Otherwise on Linux, you will need the qtpy or PyQt modules installed. qtpy also requires a python-qt-bindings module: PyQt4, PyQt5, PySide, PySide2 -PyQt4 modules are not available for Python 3, -and this module does not work with PyGObject yet. +This module does not work with PyGObject yet. """ __version__ = '1.5.27' From b9c001f8cfdb1d9cca801ed1870f83069550234f Mon Sep 17 00:00:00 2001 From: chuanzhu xu Date: Sat, 1 Jun 2019 12:12:36 -0400 Subject: [PATCH 4/4] add removed gtk support into whatsnew --- doc/source/whatsnew/v0.25.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index 89a9da4a73b35..65ef332b4122c 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -334,6 +334,7 @@ Other API Changes - The ``arg`` argument in :meth:`pandas.core.groupby.DataFrameGroupBy.agg` has been renamed to ``func`` (:issue:`26089`) - The ``arg`` argument in :meth:`pandas.core.window._Window.aggregate` has been renamed to ``func`` (:issue:`26372`) - Most Pandas classes had a ``__bytes__`` method, which was used for getting a python2-style bytestring representation of the object. This method has been removed as a part of dropping Python2 (:issue:`26447`) +- Removed support of gtk package for clipboards (:issue:`26563`) .. _whatsnew_0250.deprecations: