Skip to content

Commit

Permalink
Merge pull request #36 from jitseniesen/spy4
Browse files Browse the repository at this point in the history
PR: Compatibility changes for Spyder 4
  • Loading branch information
jitseniesen committed Sep 23, 2019
2 parents 8052536 + 14c3956 commit b5f5894
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 100 deletions.
12 changes: 3 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,18 @@ main: &main
sudo apt-get -qq update
sudo apt-get install -q libegl1-mesa
- run:
command: ./.circleci/install.sh
command: bash ./continuous_integration/circle/install.sh
- run:
command: ./.circleci/run_tests.sh
command: bash ./continuous_integration/circle/run_tests.sh
- run:
command: ./.circleci/coverage.sh
command: bash ./continuous_integration/circle/coverage.sh

jobs:
python2.7:
<<: *main
environment:
- PYTHON_VERSION: "2.7"

python3.5:
<<: *main
environment:
- PYTHON_VERSION: "3.5"

python3.6:
<<: *main
environment:
Expand All @@ -44,6 +39,5 @@ workflows:
build_and_test:
jobs:
- python2.7
- python3.5
- python3.6
- python3.7
24 changes: 0 additions & 24 deletions .circleci/install.sh

This file was deleted.

30 changes: 30 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# https://travis-ci.org/spyder-ide/spyder-line-profiler

language: generic
dist: xenial
services:
- xvfb

matrix:
fast_finish: true
include:
- env: PYTHON_VERSION=2.7 USE_CONDA=yes
- env: PYTHON_VERSION=3.6 USE_CONDA=yes
- env: PYTHON_VERSION=3.7 USE_CONDA=yes

before_install:
# Avoid annoying focus problems when running tests
# See discussion in e.g. https://github.com/spyder-ide/spyder/pull/6132
- sudo apt-get -qq update
- sudo apt-get install -y matchbox-window-manager xterm libxkbcommon-x11-0
- matchbox-window-manager&
- sleep 5

install:
- ./continuous_integration/circle/install.sh

script:
- ./continuous_integration/circle/run_tests.sh

after_success:
- ./continuous_integration/circle/coverage.sh
52 changes: 0 additions & 52 deletions appveyor.yml

This file was deleted.

File renamed without changes.
29 changes: 29 additions & 0 deletions continuous_integration/circle/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash -ex

# -- Install Miniconda
MINICONDA=Miniconda3-latest-Linux-x86_64.sh
wget https://repo.continuum.io/miniconda/$MINICONDA -O miniconda.sh
bash miniconda.sh -b -p $HOME/miniconda
source $HOME/miniconda/etc/profile.d/conda.sh


# -- Make new conda environment with required Python version
conda create -y -n test python=$PYTHON_VERSION
conda activate test


# -- Install dependencies

# Avoid problems with invalid SSL certificates
if [ "$PYTHON_VERSION" = "2.7" ]; then
conda install -q -y python=2.7.16=h9bab390_0
fi

# Install nomkl to avoid installing Intel MKL libraries
conda install -q -y nomkl

# Install main dependencies
conda install -q -y -c spyder-ide --file requirements/conda.txt

# Install test ones
conda install -q -y -c spyder-ide --file requirements/tests.txt
File renamed without changes.
2 changes: 2 additions & 0 deletions requirements/conda.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
line_profiler
spyder >=4.0.0b5
5 changes: 5 additions & 0 deletions requirements/tests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
coveralls
mock
pytest
pytest-cov
pytest-qt
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_package_data(name, extlist):


# Requirements
REQUIREMENTS = ['line_profiler', 'spyder>=3']
REQUIREMENTS = ['line_profiler', 'spyder>=4']
EXTLIST = ['.jpg', '.png', '.json', '.mo', '.ini']
LIBNAME = 'spyder_line_profiler'

Expand Down
17 changes: 6 additions & 11 deletions spyder_line_profiler/lineprofiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
from spyder.plugins.configdialog import PluginConfigPage
from spyder.utils import icon_manager as ima
from spyder.utils.qthelpers import create_action

Expand Down Expand Up @@ -78,17 +78,13 @@ class LineProfiler(SpyderPluginWidget):

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)
layout = QVBoxLayout()
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.
Expand Down Expand Up @@ -127,13 +123,14 @@ def on_first_registration(self):

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(),
Expand Down Expand Up @@ -163,10 +160,8 @@ def run_lineprofiler(self):

def analyze(self, filename):
"""Reimplement analyze method."""
if self.dockwidget and not self.ismaximized:
self.dockwidget.setVisible(True)
self.dockwidget.setFocus()
self.dockwidget.raise_()
if self.dockwidget:
self.switch_to_plugin()
self.widget.analyze(
filename=filename,
use_colors=self.get_option('use_colors', True))
6 changes: 3 additions & 3 deletions spyder_line_profiler/widgets/lineprofiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,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
Expand Down Expand Up @@ -88,7 +88,7 @@ class LineProfilerWidget(QWidget):
def __init__(self, parent):
QWidget.__init__(self, parent)
# Need running QApplication before importing runconfig
from spyder.plugins import runconfig
from spyder.preferences import runconfig
self.runconfig = runconfig
self.spyder_pythonpath = None

Expand Down

0 comments on commit b5f5894

Please sign in to comment.