Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Update CI and requirements for Spyder 6 and add some testing #14

Merged
merged 15 commits into from
Feb 28, 2023
Merged
5 changes: 5 additions & 0 deletions .github/workflows/linux-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
matrix:
PYTHON_VERSION: ['3.8', '3.9', '3.10']
USE_CONDA: ['True', 'False']
timeout-minutes: 15
steps:
- name: Checkout branch
uses: actions/checkout@v2
Expand Down Expand Up @@ -49,6 +50,10 @@ jobs:
run: |
pip install -r requirements/conda.txt
pip install -r requirements/tests.txt
- name: Install Spyder from master branch (Future Spyder 6)
shell: bash -l {0}
run: |
pip install git+https://github.com/spyder-ide/spyder.git@master
- name: Install Package
shell: bash -l {0}
run: pip install --no-deps -e .
Expand Down
5 changes: 3 additions & 2 deletions requirements/conda.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
envs-manager>=0.1.2
envs-manager>=0.1.3
qtawesome
qtpy
setuptools
spyder>=5.4.2
# Uncomment when Spyder 6 is available
# spyder>=6
11 changes: 6 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
version=__version__,
author="Spyder Development Team and spyder-env-manager contributors",
author_email="[email protected]",
description="Spyder 5+ plugin to manage Python virtual environments and packages",
description="Spyder 6+ plugin to manage Python virtual environments and packages",
license="MIT license",
url="https://github.com/spyder-ide/spyder-env-manager",
python_requires=">= 3.7",
python_requires=">= 3.8",
install_requires=[
"envs-manager>=0.1.1",
"envs-manager>=0.1.3",
"qtpy",
"qtawesome",
"spyder>=5.4.0",
"spyder>=6",
],
packages=find_packages(),
entry_points={
Expand All @@ -38,9 +38,10 @@
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
Expand Down
4 changes: 2 additions & 2 deletions spyder_env_manager/spyder/confpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def setup_page(self):
conda_like_path_label.setToolTip(_("Path to the conda/micromamba executable"))
conda_like_path_label.setWordWrap(True)

conda_like_path = QLabel(self.get_option("conda_file_executable_path"))
conda_like_path = QLabel(self.get_option("conda_file_executable_path", None))
conda_like_path.setTextInteractionFlags(Qt.TextSelectableByMouse)
conda_like_path.setWordWrap(True)

Expand All @@ -42,7 +42,7 @@ def setup_page(self):
)
environments_path_label.setWordWrap(True)

environments_path = QLabel(self.get_option("environments_path"))
environments_path = QLabel(self.get_option("environments_path", None))
environments_path.setTextInteractionFlags(Qt.TextSelectableByMouse)
environments_path.setWordWrap(True)

Expand Down
2 changes: 1 addition & 1 deletion spyder_env_manager/spyder/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_name():
return _("Environments Manager")

def get_description(self):
return _("Spyder 5+ plugin to manage Python virtual environments and packages")
return _("Spyder 6+ plugin to manage Python virtual environments and packages")

def get_icon(self):
return qta.icon("mdi.archive", color=ima.MAIN_FG_COLOR)
Expand Down
2 changes: 1 addition & 1 deletion spyder_env_manager/spyder/widgets/helper_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self, parent, title, messages, types, contents):
super().__init__(parent, Qt.WindowTitleHint | Qt.WindowCloseButtonHint)

self.resize(450, 130)
self.setWindowTitle(_(title))
self.setWindowTitle(title)
self.setModal(True)
self.lineedits = {}

Expand Down
27 changes: 12 additions & 15 deletions spyder_env_manager/spyder/widgets/main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ class SpyderEnvManagerWidget(PluginMainWidget):
Path to the environment Python interpreter.
"""

def __init__(self, name=None, plugin=None, parent=None):
super().__init__(name, plugin, parent)
def __init__(self, name, plugin, parent=None):
super().__init__(name, plugin, parent=parent)

# General attributes
self.actions_enabled = True
Expand All @@ -137,12 +137,11 @@ def __init__(self, name=None, plugin=None, parent=None):
self.manager_worker = None

# Select environment widget
root_path = self.get_conf("environments_path")
envs, _ = Manager.list_environments(
backend=CondaLikeInterface.ID,
root_path=self.get_conf("environments_path", DEFAULT_BACKENDS_ROOT_PATH),
external_executable=self.get_conf(
"conda_file_executable_path", conda_like_executable()
),
root_path=root_path,
external_executable=self.get_conf("conda_file_executable_path"),
)
self.select_environment = QComboBox(self)
self.select_environment.ID = SpyderEnvManagerWidgetActions.SelectEnvironment
Expand All @@ -158,12 +157,12 @@ def __init__(self, name=None, plugin=None, parent=None):
QComboBox.AdjustToMinimumContentsLength
)
self.select_environment.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
selected_environment = self.get_conf("selected_environment", None)
selected_environment = self.get_conf("selected_environment")
if selected_environment:
self.select_environment.setCurrentText(selected_environment)

# Usage widget
self.css_path = self.get_conf("css_path", CSS_PATH, "appearance")
self.css_path = self.get_conf("css_path", str(CSS_PATH), "appearance")
self.infowidget = FrameWebView(self)
if WEBENGINE:
self.infowidget.web_widget.page().setBackgroundColor(QColor(MAIN_BG_COLOR))
Expand Down Expand Up @@ -359,8 +358,8 @@ def current_environment_changed(self, index=None):

def update_actions(self):
if self.actions_enabled:
current_environment = self.select_environment.currentText()
environments_available = current_environment != "No environments available"
current_environment_path = self.select_environment.currentData()
environments_available = current_environment_path is not None
actions_ids = [
SpyderEnvManagerWidgetActions.InstallPackage,
SpyderEnvManagerWidgetActions.DeleteEnvironment,
Expand Down Expand Up @@ -520,9 +519,7 @@ def _environment_as_custom_interpreter(self, environment_path=None):
environment_path = self.select_environment.currentData()
if not environment_path:
return
external_executable = self.get_conf(
"conda_file_executable_path", conda_like_executable()
)
external_executable = self.get_conf("conda_file_executable_path")
backend = "conda-like"
manager = Manager(
backend,
Expand Down Expand Up @@ -761,9 +758,9 @@ def _run_env_manager_action(
*manager_action_args,
**manager_action_kwargs,
)
self.manager_worker.moveToThread(self.env_manager_action_thread)
self.manager_worker.sig_ready.connect(on_ready)
self.manager_worker.sig_ready.connect(self.env_manager_action_thread.quit)
self.manager_worker.moveToThread(self.env_manager_action_thread)
self.env_manager_action_thread.started.connect(self.manager_worker.start)
self.start_spinner()
self.env_manager_action_thread.start()
Expand Down Expand Up @@ -1038,7 +1035,7 @@ def _message_new_environment(self):
contents = [
{"conda-like"},
{},
["3.7.15", "3.8.15", "3.9.15", "3.10.8"],
["3.8.16", "3.9.16", "3.10.9", "3.11.0"],
]
self._message_box_editable(
title,
Expand Down
6 changes: 6 additions & 0 deletions spyder_env_manager/tests/data/import_env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name:
channels:
- https://conda.anaconda.org/conda-forge
dependencies:
- packaging=21.3
- python=3.10.5
36 changes: 36 additions & 0 deletions spyder_env_manager/tests/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# ----------------------------------------------------------------------------
# Copyright © 2022, Spyder Development Team and spyder-env-manager contributors
#
# Licensed under the terms of the MIT license
# ----------------------------------------------------------------------------
"""
Spyder Env Manager ConfigPage tests.
"""

# Third-party library imports
import pytest

# Spyder imports
from spyder.plugins.preferences.widgets.configdialog import ConfigDialog

# Local imports
from spyder_env_manager.spyder.confpage import SpyderEnvManagerConfigPage
from spyder_env_manager.tests.test_plugin import spyder_env_manager_conf


def test_config(spyder_env_manager_conf, qtbot):
"""Test that config page can be created and shown."""
dlg = ConfigDialog()
page = SpyderEnvManagerConfigPage(
spyder_env_manager_conf, parent=spyder_env_manager_conf.main
)
page.initialize()
dlg.add_page(page)
qtbot.addWidget(dlg)
dlg.show()
# no assert, just check that the config page can be created


if __name__ == "__main__":
pytest.main()
2 changes: 1 addition & 1 deletion spyder_env_manager/tests/test_main_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ def get_conf(self, option, default=None, section=None):
monkeypatch.setattr(SpyderEnvManagerWidget, "get_conf", get_conf)

SpyderEnvManagerWidget.CONF_SECTION = CONF_SECTION
widget = SpyderEnvManagerWidget(None)
widget = SpyderEnvManagerWidget(None, None)
widget.setup()
widget.show()
Loading