Hello community, here is the log from the commit of package python-spyder-line-profiler for openSUSE:Factory checked in at 2020-02-03 11:13:34 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-spyder-line-profiler (Old) and /work/SRC/openSUSE:Factory/.python-spyder-line-profiler.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-spyder-line-profiler" Mon Feb 3 11:13:34 2020 rev:4 rq:768884 version:0.2.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-spyder-line-profiler/python-spyder-line-profiler.changes 2019-11-07 23:18:22.736655614 +0100 +++ /work/SRC/openSUSE:Factory/.python-spyder-line-profiler.new.26092/python-spyder-line-profiler.changes 2020-02-03 11:13:39.829855410 +0100 @@ -1,0 +2,15 @@ +Thu Jan 30 19:37:45 UTC 2020 - Todd R <toddrme2...@gmail.com> + +- Update to 0.2.0 + + Issues Closed + * Sorting by time / % not working correctly + * Update plugin to Spyder v4 + + Pull Requests Merged + * PR: Add natural sort for columns + * PR: Compatibility changes for Spyder 4 + * PR: Fix continuous integration services + * PR: "Profile by line" Button Behavior + * Update readme: Plugin can now be installed using conda or pip + * Add conda recipe + +------------------------------------------------------------------- Old: ---- spyder_line_profiler-0.1.1.tar.gz New: ---- spyder_line_profiler-0.2.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-spyder-line-profiler.spec ++++++ --- /var/tmp/diff_new_pack.HONwKD/_old 2020-02-03 11:13:41.517856263 +0100 +++ /var/tmp/diff_new_pack.HONwKD/_new 2020-02-03 11:13:41.521856265 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-spyder-line-profiler # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-spyder-line-profiler -Version: 0.1.1 +Version: 0.2.0 Release: 0 Summary: Line profiler plugin for the Spyder IDE License: MIT ++++++ spyder_line_profiler-0.1.1.tar.gz -> spyder_line_profiler-0.2.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spyder_line_profiler-0.1.1/CHANGELOG.md new/spyder_line_profiler-0.2.0/CHANGELOG.md --- old/spyder_line_profiler-0.1.1/CHANGELOG.md 2017-03-26 21:33:35.000000000 +0200 +++ new/spyder_line_profiler-0.2.0/CHANGELOG.md 2019-12-18 11:09:43.000000000 +0100 @@ -1,9 +1,31 @@ # History of changes +## Version 0.2.0 (2019/12/18) + +This release updates the plugin to be used with Spyder 4 and fixes some bugs. + +### Issues Closed + +* [Issue 33](https://github.com/spyder-ide/spyder-line-profiler/issues/33) - Sorting by time / % not working correctly ([PR 38](https://github.com/spyder-ide/spyder-line-profiler/pull/38)) +* [Issue 26](https://github.com/spyder-ide/spyder-line-profiler/issues/26) - Update plugin to Spyder v4 ([PR 36](https://github.com/spyder-ide/spyder-line-profiler/pull/36)) + +In this release 2 issues were closed. + +### Pull Requests Merged + +* [PR 38](https://github.com/spyder-ide/spyder-line-profiler/pull/38) - PR: Add natural sort for columns ([33](https://github.com/spyder-ide/spyder-line-profiler/issues/33)) +* [PR 36](https://github.com/spyder-ide/spyder-line-profiler/pull/36) - PR: Compatibility changes for Spyder 4 ([26](https://github.com/spyder-ide/spyder-line-profiler/issues/26)) +* [PR 31](https://github.com/spyder-ide/spyder-line-profiler/pull/31) - PR: Fix continuous integration services +* [PR 30](https://github.com/spyder-ide/spyder-line-profiler/pull/30) - PR: "Profile by line" Button Behavior +* [PR 24](https://github.com/spyder-ide/spyder-line-profiler/pull/24) - Update readme: Plugin can now be installed using conda or pip +* [PR 23](https://github.com/spyder-ide/spyder-line-profiler/pull/23) - Add conda recipe ([15](https://github.com/spyder-ide/spyder-line-profiler/issues/15)) + +In this release 6 pull requests were closed. + ## Version 0.1.1 (2017/03/26) -This version improves the packaging. The code itself was not changed. +This version improves the packaging. The code itself was not changed. ### Pull Requests Merged diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spyder_line_profiler-0.1.1/PKG-INFO new/spyder_line_profiler-0.2.0/PKG-INFO --- old/spyder_line_profiler-0.1.1/PKG-INFO 2017-03-26 21:36:19.000000000 +0200 +++ new/spyder_line_profiler-0.2.0/PKG-INFO 2019-12-18 11:12:27.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: spyder_line_profiler -Version: 0.1.1 +Version: 0.2.0 Summary: Plugin for the Spyder IDE that integrates the Python line profiler. Home-page: https://github.com/spyder-ide/spyder-line-profiler Author: Spyder Project Contributors diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spyder_line_profiler-0.1.1/README.rst new/spyder_line_profiler-0.2.0/README.rst --- old/spyder_line_profiler-0.1.1/README.rst 2017-03-20 22:18:02.000000000 +0100 +++ new/spyder_line_profiler-0.2.0/README.rst 2018-11-25 13:34:58.000000000 +0100 @@ -16,9 +16,6 @@ Build information ----------------- -.. image:: https://travis-ci.org/spyder-ide/spyder-line-profiler.svg?branch=master - :target: https://travis-ci.org/spyder-ide/spyder-line-profiler - .. image:: https://ci.appveyor.com/api/projects/status/u8m20qgel4j155pn/branch/master?svg=true :target: https://ci.appveyor.com/project/spyder-ide/spyder-line-profiler @@ -28,40 +25,37 @@ .. image:: https://coveralls.io/repos/github/spyder-ide/spyder-line-profiler/badge.svg?branch=master :target: https://coveralls.io/github/spyder-ide/spyder-line-profiler?branch=master -.. image:: https://www.quantifiedcode.com/api/v1/project/54e5f210a2dd4d979438fd8574650822/badge.svg - :target: https://www.quantifiedcode.com/api/project/54e5f210a2dd4d979438fd8574650822 - -.. image:: https://scrutinizer-ci.com/g/spyder-ide/spyder-line-profiler/badges/quality-score.png?b=master - :target: https://scrutinizer-ci.com/g/spyder-ide/spyder-line-profiler/?branch=master) - Description ----------- -This is a plugin to run the python `line profiler <https://github.com/rkern/line_profiler>`_ from within the python IDE `spyder <https://github.com/spyder-ide/spyder>`_. +This is a plugin to run the python `line profiler <https://github.com/rkern/line_profiler>`_ +from within the python IDE `spyder <https://github.com/spyder-ide/spyder>`_. The code is an adaptation of the profiler plugin integrated in spyder. Install instructions -------------------- -See https://github.com/spyder-ide/spyder/wiki/User-plugins but in -short, the following command installs the development version of the -line-profiler plugin: - -:: - - pip install git+git://github.com/spyder-ide/spyder-line-profiler.git - -The plugin is not yet included in PyPI. +The line-profiler plugin is available in the ``spyder-ide`` channel in +Anaconda and in PyPI, so it can be installed with the following +commands: + +* Using Anaconda: ``conda install -c spyder-ide spyder-line-profiler`` +* Using pip: ``pip install spyder-line-profiler`` + +All dependencies will be automatically installed. You have to restart +Spyder before you can use the plugin. -You need to also install `Spyder <https://github.com/spyder-ide/spyder>`_ (version 3.0 or higher) and the `line profiler <https://github.com/rkern/line_profiler>`_ . Usage ----- -Add a ``@profile`` decorator to the functions that you wish to profile then press Shift+F10 (line profiler default) to run the profiler on the current script, or go to ``Run > Profile line by line``. +Add a ``@profile`` decorator to the functions that you wish to profile then press Shift+F10 +(line profiler default) to run the profiler on the current script, or go to +``Run > Profile line by line``. -The results will be shown in a dockwidget, grouped by function. Lines with a stronger color take more time to run. +The results will be shown in a dockwidget, grouped by function. Lines with a stronger color +take more time to run. Screenshot diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spyder_line_profiler-0.1.1/setup.cfg new/spyder_line_profiler-0.2.0/setup.cfg --- old/spyder_line_profiler-0.1.1/setup.cfg 2017-03-26 21:36:19.000000000 +0200 +++ new/spyder_line_profiler-0.2.0/setup.cfg 2019-12-18 11:12:27.000000000 +0100 @@ -1,5 +1,4 @@ [egg_info] tag_build = tag_date = 0 -tag_svn_revision = 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spyder_line_profiler-0.1.1/setup.py new/spyder_line_profiler-0.2.0/setup.py --- old/spyder_line_profiler-0.1.1/setup.py 2017-03-26 21:30:05.000000000 +0200 +++ new/spyder_line_profiler-0.2.0/setup.py 2019-10-23 17:05:11.000000000 +0200 @@ -38,7 +38,7 @@ # Requirements -REQUIREMENTS = ['line_profiler', 'spyder>=3'] +REQUIREMENTS = ['line_profiler', 'spyder>=4'] EXTLIST = ['.jpg', '.png', '.json', '.mo', '.ini'] LIBNAME = 'spyder_line_profiler' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spyder_line_profiler-0.1.1/spyder_line_profiler/__init__.py new/spyder_line_profiler-0.2.0/spyder_line_profiler/__init__.py --- old/spyder_line_profiler-0.1.1/spyder_line_profiler/__init__.py 2017-03-26 21:33:58.000000000 +0200 +++ new/spyder_line_profiler-0.2.0/spyder_line_profiler/__init__.py 2019-12-18 11:11:39.000000000 +0100 @@ -4,7 +4,7 @@ # Licensed under the terms of the MIT License # (see LICENSE.txt for details) -__version__ = '0.1.1' +__version__ = '0.2.0' # ============================================================================= # The following statements are required to register this 3rd party plugin: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spyder_line_profiler-0.1.1/spyder_line_profiler/lineprofiler.py new/spyder_line_profiler-0.2.0/spyder_line_profiler/lineprofiler.py --- old/spyder_line_profiler-0.1.1/spyder_line_profiler/lineprofiler.py 2017-03-26 21:30:05.000000000 +0200 +++ new/spyder_line_profiler-0.2.0/spyder_line_profiler/lineprofiler.py 2019-10-23 17:05:11.000000000 +0200 @@ -14,9 +14,9 @@ from spyder.utils.qthelpers import qapplication MAIN_APP = qapplication() +from spyder.api.plugins import SpyderPluginWidget +from spyder.api.preferences import PluginConfigPage from spyder.config.base import get_translation -from spyder.plugins import SpyderPluginWidget, runconfig -from spyder.plugins.configdialog import PluginConfigPage from spyder.utils import icon_manager as ima from spyder.utils.qthelpers import create_action @@ -78,7 +78,6 @@ def __init__(self, parent=None): SpyderPluginWidget.__init__(self, parent) - self.main = parent # Spyder 3 compatibility # Create widget and add to dockwindow self.widget = LineProfilerWidget(self.main) @@ -86,8 +85,15 @@ layout.addWidget(self.widget) self.setLayout(layout) - # Initialize plugin - self.initialize_plugin() + def update_pythonpath(self): + """ + Update the PYTHONPATH used when running the line_profiler. + + This function is called whenever the Python path set in Spyder changes. + It synchronizes the PYTHONPATH in the line_profiler widget with the + PYTHONPATH in Spyder. + """ + self.widget.spyder_pythonpath = self.main.get_spyder_pythonpath() # --- SpyderPluginWidget API ---------------------------------------------- def get_plugin_title(self): @@ -117,9 +123,14 @@ def register_plugin(self): """Register plugin in Spyder's main window.""" + super(LineProfiler, self).register_plugin() + + # Spyder PYTHONPATH + self.update_pythonpath() + self.main.sig_pythonpath_changed.connect(self.update_pythonpath) + self.edit_goto.connect(self.main.editor.load) self.widget.redirect_stdio.connect(self.main.redirect_internalshell_stdio) - self.main.add_dockwidget(self) lineprofiler_act = create_action(self, _("Profile line by line"), icon=self.get_plugin_icon(), @@ -149,19 +160,8 @@ def analyze(self, filename): """Reimplement analyze method.""" - if self.dockwidget and not self.ismaximized: - self.dockwidget.setVisible(True) - self.dockwidget.setFocus() - self.dockwidget.raise_() - pythonpath = self.main.get_spyder_pythonpath() - runconf = runconfig.get_run_configuration(filename) - wdir, args = None, None - if runconf is not None: - if runconf.wdir_enabled: - wdir = runconf.wdir - if runconf.args_enabled: - args = runconf.args - + if self.dockwidget: + self.switch_to_plugin() self.widget.analyze( - filename, wdir=wdir, args=args, pythonpath=pythonpath, + filename=filename, use_colors=self.get_option('use_colors', True)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spyder_line_profiler-0.1.1/spyder_line_profiler/widgets/lineprofiler.py new/spyder_line_profiler-0.2.0/spyder_line_profiler/widgets/lineprofiler.py --- old/spyder_line_profiler-0.1.1/spyder_line_profiler/widgets/lineprofiler.py 2017-03-20 22:18:02.000000000 +0100 +++ new/spyder_line_profiler-0.2.0/spyder_line_profiler/widgets/lineprofiler.py 2019-12-18 11:10:26.000000000 +0100 @@ -15,6 +15,7 @@ import hashlib import inspect import linecache +import re import os import os.path as osp import time @@ -30,11 +31,11 @@ # Local imports from spyder.config.base import get_conf_path, get_translation +from spyder.plugins.variableexplorer.widgets.texteditor import TextEditor from spyder.utils import programs +from spyder.utils.misc import add_pathlist_to_PYTHONPATH from spyder.utils.qthelpers import create_toolbutton, get_icon from spyder.widgets.comboboxes import PythonModulesComboBox -from spyder.utils.misc import add_pathlist_to_PYTHONPATH -from spyder.widgets.variableexplorer.texteditor import TextEditor try: from spyder.py3compat import to_text_string, getcwd, pickle @@ -68,6 +69,37 @@ WEBSITE_URL = 'http://pythonhosted.org/line_profiler/' +class TreeWidgetItem(QTreeWidgetItem): + """ + An extension of QTreeWidgetItem that replaces the sorting behaviour + such that the sorting is not purely by ASCII index but by natural + sorting, e.g. multi-digit numbers sorted based on their value instead + of individual digits. + + Taken from + https://stackoverflow.com/questions/21030719/sort-a-pyside-qtgui- + qtreewidget-by-an-alpha-numeric-column/ + """ + def __lt__(self, other): + """ + Compare a widget text entry to another entry. + """ + column = self.treeWidget().sortColumn() + key1 = self.text(column) + key2 = other.text(column) + return self.natural_sort_key(key1) < self.natural_sort_key(key2) + + @staticmethod + def natural_sort_key(key): + """ + Natural sorting for both numbers and strings containing numbers. + """ + regex = '(\d*\.\d+|\d+)' + parts = re.split(regex, key) + return tuple((e if i % 2 == 0 else float(e)) + for i, e in enumerate(parts)) + + def is_lineprofiler_installed(): """ Checks if the program and the library for line_profiler is installed. @@ -87,6 +119,10 @@ def __init__(self, parent): QWidget.__init__(self, parent) + # Need running QApplication before importing runconfig + from spyder.preferences import runconfig + self.runconfig = runconfig + self.spyder_pythonpath = None self.setWindowTitle("Line profiler") @@ -105,7 +141,7 @@ self, icon=get_icon('run.png'), text=_("Profile by line"), tip=_("Run line profiler"), - triggered=self.start, text_beside_icon=True) + triggered=(lambda checked=False: self.analyze()), text_beside_icon=True) self.stop_button = create_toolbutton( self, icon=get_icon('terminate.png'), @@ -181,23 +217,42 @@ else: pass # self.show_data() - def analyze(self, filename, wdir=None, args=None, pythonpath=None, + def analyze(self, filename=None, wdir=None, args=None, pythonpath=None, use_colors=True): self.use_colors = use_colors if not is_lineprofiler_installed(): return self.kill_if_running() - #index, _data = self.get_data(filename) - index = None # FIXME: storing data is not implemented yet - if index is None: - self.filecombo.addItem(filename) - self.filecombo.setCurrentIndex(self.filecombo.count()-1) - else: - self.filecombo.setCurrentIndex(self.filecombo.findText(filename)) - self.filecombo.selected() + #index, _data = self.get_data(filename) # FIXME: storing data is not implemented yet + if filename is not None: + filename = osp.abspath(to_text_string(filename)) + index = self.filecombo.findText(filename) + if index == -1: + self.filecombo.addItem(filename) + self.filecombo.setCurrentIndex(self.filecombo.count()-1) + else: + self.filecombo.setCurrentIndex(index) + self.filecombo.selected() if self.filecombo.is_valid(): + filename = to_text_string(self.filecombo.currentText()) + runconf = self.runconfig.get_run_configuration(filename) + if runconf is not None: + if wdir is None: + if runconf.wdir_enabled: + wdir = runconf.wdir + elif runconf.cw_dir: + wdir = os.getcwd() + elif runconf.file_dir: + wdir = osp.dirname(filename) + elif runconf.fixed_dir: + wdir = runconf.dir + if args is None: + if runconf.args_enabled: + args = runconf.args if wdir is None: wdir = osp.dirname(filename) + if pythonpath is None: + pythonpath = self.spyder_pythonpath self.start(wdir, args, pythonpath) def select_file(self): @@ -473,7 +528,7 @@ def populate_tree(self): """Create each item (and associated data) in the tree""" if not self.stats: - warn_item = QTreeWidgetItem(self) + warn_item = TreeWidgetItem(self) warn_item.setData( 0, Qt.DisplayRole, _('No timings to display. ' @@ -496,7 +551,7 @@ # Function name and position filename, start_line_no, func_name = func_info func_stats, func_total_time = func_data - func_item = QTreeWidgetItem(self) + func_item = TreeWidgetItem(self) func_item.setData( 0, Qt.DisplayRole, _('{func_name} ({time_ms:.3f}ms) in file "{filename}", ' @@ -525,7 +580,7 @@ # Lines of code for line_info in func_stats: - line_item = QTreeWidgetItem(func_item) + line_item = TreeWidgetItem(func_item) (line_no, code_line, line_total_time, time_per_hit, hits, percent) = line_info self.fill_item( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spyder_line_profiler-0.1.1/spyder_line_profiler.egg-info/PKG-INFO new/spyder_line_profiler-0.2.0/spyder_line_profiler.egg-info/PKG-INFO --- old/spyder_line_profiler-0.1.1/spyder_line_profiler.egg-info/PKG-INFO 2017-03-26 21:36:19.000000000 +0200 +++ new/spyder_line_profiler-0.2.0/spyder_line_profiler.egg-info/PKG-INFO 2019-12-18 11:12:27.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: spyder-line-profiler -Version: 0.1.1 +Version: 0.2.0 Summary: Plugin for the Spyder IDE that integrates the Python line profiler. Home-page: https://github.com/spyder-ide/spyder-line-profiler Author: Spyder Project Contributors diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spyder_line_profiler-0.1.1/spyder_line_profiler.egg-info/requires.txt new/spyder_line_profiler-0.2.0/spyder_line_profiler.egg-info/requires.txt --- old/spyder_line_profiler-0.1.1/spyder_line_profiler.egg-info/requires.txt 2017-03-26 21:36:19.000000000 +0200 +++ new/spyder_line_profiler-0.2.0/spyder_line_profiler.egg-info/requires.txt 2019-12-18 11:12:27.000000000 +0100 @@ -1,2 +1,2 @@ line_profiler -spyder>=3 +spyder>=4