Skip to content
New issue

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

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

Already on GitHub? # to your account

Update readme, fix pyproject and add more tests #5

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 38 additions & 5 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,40 @@ concurrency:

jobs:
test:
name: ${{ matrix.platform }}, py${{ matrix.python-version }}, napari ${{ matrix.napari }}
name: ${{ matrix.platform }}, py${{ matrix.python-version }}, napari ${{ matrix.napari }}, ${{ matrix.tool }}
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest, macos-13]
python-version: ["3.9", "3.10", "3.11"]
napari: ["latest", "repo"]
tool: ["pip", "conda"]
exclude:
# TODO: Remove when we have a napari release with the plugin manager changes
- napari: "latest"
# TODO: PyQt / PySide wheels missing
- python-version: "3.11"
platform: "windows-latest"
- python-version: "3.11"
backend: pyside2

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.python-version }} - pip
if: matrix.tool == 'pip'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Set up Python ${{ matrix.python-version }} - conda
if: matrix.tool == 'conda'
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
python-version: ${{ matrix.python-version }}

- uses: tlambert03/setup-qt-libs@v1

# strategy borrowed from vispy for installing opengl libs on windows
Expand All @@ -58,14 +69,36 @@ jobs:
powershell gl-ci-helpers/appveyor/install_opengl.ps1
if (Test-Path -Path "C:\Windows\system32\opengl32.dll" -PathType Leaf) {Exit 0} else {Exit 1}

- name: Install dependencies
- name: Install dependencies without tox-conda
if: matrix.tool == 'pip'
run: |
python -m pip install --upgrade pip
pip install setuptools tox tox-gh-actions
python -m pip install setuptools tox tox-gh-actions

- name: Install dependencies including tox-conda
if: matrix.tool == 'conda'
shell: bash -el {0}
run: |
python -m pip install --upgrade pip
python -m pip install setuptools 'tox<4' tox-gh-actions tox-conda

- name: Test with tox - pip
if: matrix.tool == 'pip'
uses: aganders3/headless-gui@v2
with:
run: python -m tox -vv
env:
PYVISTA_OFF_SCREEN: True # required for opengl on windows
NAPARI: ${{ matrix.napari }}
FORCE_COLOR: 1
# PySide6 only functional with Python 3.10+
TOX_SKIP_ENV: ".*py39-PySide6.*"

- name: Test with tox
- name: Test with tox - conda
if: matrix.tool == 'conda'
uses: aganders3/headless-gui@v2
with:
shell: bash -el {0}
run: python -m tox -vv
env:
PYVISTA_OFF_SCREEN: True # required for opengl on windows
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# napari-update-checker

[![License](https://img.shields.io/pypi/l/napari-update-checker.svg?color=green)](https://github.com/napari/update-checker/raw/main/LICENSE)
[![License](https://img.shields.io/pypi/l/napari-update-checker.svg?color=green)](https://raw.githubusercontent.com/napari/update-checker/refs/heads/main/LICENSE.txt)
[![PyPI](https://img.shields.io/pypi/v/napari-update-checker.svg?color=green)](https://pypi.org/project/napari-update-checker)
[![Python Version](https://img.shields.io/pypi/pyversions/napari-update-checker.svg?color=green)](https://python.org)
[![tests](https://github.com/napari/update-checker/actions/workflows/test_and_deploy.yml/badge.svg)](https://github.com/napari/update-checker/actions/workflows/test_and_deploy.yml)
Expand Down
7 changes: 7 additions & 0 deletions napari_update_checker/_tests/test_qt_update_checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from napari_update_checker.qt_update_checker import UpdateChecker


def test_widget(qtbot):
w = UpdateChecker()
w.show()
w.close()
2 changes: 1 addition & 1 deletion napari_update_checker/_tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_conda_forge_releases():
pass


def test_get_latest_version():
def test_get_latest_version(monkeypatch):
result = get_latest_version(github=None)
assert result
result = get_latest_version(github=True)
Expand Down
7 changes: 5 additions & 2 deletions napari_update_checker/qt_update_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
from contextlib import suppress
from datetime import date
from typing import Optional

import packaging.version
from napari import __version__
Expand Down Expand Up @@ -82,11 +83,13 @@ def _check_time(self):
def check(self):
self._check_time()
self._worker = create_worker(get_latest_version)
self._worker.yielded.connect(self.show_version_info)
self._worker.returned.connect(self.show_version_info)
self._worker.start()

@ensure_main_thread
def show_version_info(self, latest_version: packaging.version.Version):
def show_version_info(
self, latest_version: Optional[packaging.version.Version] = None
):
my_version = self._current_version
remote_version = latest_version

Expand Down
3 changes: 2 additions & 1 deletion napari_update_checker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def get_latest_version(github: Optional[bool] = None):
return None

if versions:
yield packaging.version.parse(versions[-1])
return packaging.version.parse(versions[-1])
return None


def is_conda_environment(path):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ docs = [
]

[project.urls]
homepage = "https://github.com/napari/napari-plugin-manager"
homepage = "https://github.com/napari/update-checker"

[tool.black]
target-version = ['py39', 'py310', 'py311']
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ isolated_build = true

[gh-actions]
python =
3.8: py38
3.9: py39
3.10: py310
3.11: py311
Expand Down