Skip to content

Commit

Permalink
Update repo (#69)
Browse files Browse the repository at this point in the history
* chore: update pyproject

* update pyproject and linting

* update readme

* update tests

* remove tox

* install backend

* Update pyproject.toml

Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>

* change deploy

* Update .github/workflows/ci.yml

Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>

* add more explicit deps

* bump setup mini

* small cleanup

* use miniforge

* Update .github/workflows/ci.yml to use conda not mamba

* Update README.md

Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>

---------

Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>
  • Loading branch information
tlambert03 and psobolewskiPhD authored Jan 7, 2025
1 parent 91ee213 commit 5ec1a5b
Show file tree
Hide file tree
Showing 17 changed files with 159 additions and 194 deletions.
96 changes: 44 additions & 52 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ name: CI

on:
push:
branches:
- main
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
branches: [main]
tags: ["v*"] # Push events to matching v*, i.e. v1.0, v20.15.10
pull_request:
branches:
- main
branches: [main]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check-manifest:
# check-manifest is a tool that checks that all files in version control are
# included in the sdist (unless explicitly excluded)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -29,72 +28,65 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10"]
backend: [pyqt5]
include:
- platform: ubuntu-latest
python-version: 3.7
backend: pyqt5
platform: [ubuntu-latest, macos-13, macos-latest, windows-latest]
python-version: ["3.9", "3.10"]
backend: [PyQt5]

steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
channels: conda-forge
channel-priority: strict
miniforge-version: "latest"
python-version: ${{ matrix.python-version }}

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

- name: Install Windows OpenGL
if: runner.os == 'Windows'
run: |
git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git
powershell gl-ci-helpers/appveyor/install_opengl.ps1
- uses: pyvista/setup-headless-display-action@v3
with:
qt: true

- name: Install dependencies
run: |
conda install omero-py
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools tox tox-conda tox-gh-actions
python -m pip install .[test]
python -m pip install ${{ matrix.backend }}
- name: Test with tox
uses: aganders3/headless-gui@v1.2
with:
shell: bash -el {0}
run: python -m tox
env:
PLATFORM: ${{ matrix.platform }}
PYTHON: ${{ matrix.python-version }}
PYVISTA_OFF_SCREEN: True
BACKEND: ${{ matrix.backend }}
- name: Test
run: pytest --color=yes --cov=napari_omero --cov-report=xml

- name: Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

deploy:
# this will run when you have tagged a commit, starting with "v*"
# and requires that you have put your twine API key in your
needs: [test]
if: github.repository == 'tlambert03/napari-omero' && contains(github.ref, 'tags')
if: success() && startsWith(github.ref, 'refs/tags/') && github.repository == 'tlambert03/napari-omero'
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
fetch-depth: 0

- name: 🐍 Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U build twine
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_password }}

- name: 👷 Build
run: |
git tag
python -m pip install build
python -m build
twine check dist/*
twine upload dist/*
- name: 🚢 Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

- uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: './dist/*'
14 changes: 5 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,19 @@ ci:

repos:
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.12.2
rev: v0.23
hooks:
- id: validate-pyproject

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.263
rev: v0.8.6
hooks:
- id: ruff
args: [--fix]

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
args: [--fix, --unsafe-fixes]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.2.0
rev: v1.14.1
hooks:
- id: mypy
files: "^src/"
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ omero napari view Image:1

## installation

Requires python 3.7 - 3.10.
While this package supports anything above python 3.9,
In practice, python support is limited by `omero-py` and `zeroc-ice`,
compatibility, which is limited to python <=3.10 at the time of writing.

### from conda

It's easiest to install `omero-py` from conda, so the recommended procedure
is to install everything from conda, using the `conda-forge` channel

```python
```sh
conda install -c conda-forge napari-omero
```

Expand All @@ -100,7 +102,7 @@ conda install -c conda-forge napari-omero
`omero-py`

```sh
conda create -n omero -c conda-forge python=3.9 omero-py
conda create -n omero -c conda-forge python=3.10 omero-py
conda activate omero
pip install napari-omero[all] # the [all] here is the same as `napari[all]`
```
Expand Down Expand Up @@ -136,15 +138,15 @@ conda env create -n napari-omero python=3.10 omero-py
# activate the new env
conda activate napari-omero

# install in editable mode
pip install -e ".[all, dev, test]" # quotes are needed on zsh
# install in editable mode with dev dependencies
pip install -e ".[dev]" # quotes are needed on zsh
```

To maintain good code quality, this repo uses
[ruff](https://github.com/astral-sh/ruff),
[mypy](https://github.com/python/mypy), and
[black](https://github.com/psf/black). To enforce code quality when you commit
code, you can install pre-commit
[mypy](https://github.com/python/mypy).

To enforce code quality when you commit code, you can install pre-commit

```bash
# install pre-commit which will run code checks prior to commits
Expand Down
75 changes: 46 additions & 29 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,26 @@ build-backend = "hatchling.build"
source = "vcs"

[tool.hatch.build.targets.wheel]
packages = ["src/napari_omero", "src/omero/plugins"]
only-include = ["src"]
sources = ["src"]

# https://peps.python.org/pep-0621/
[project]
name = "napari-omero"
dynamic = ["version"]
description = "napari/OMERO interoperability"
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.9"
license = { text = "GPL-2.0-or-later" }
authors = [
{ name = "Talley Lambert", email = "talley.lambert@gmail.com" },
{ name = "Will Moore" },
{ name = "Will Moore", email = "w.moore@dundee.ac.uk" },
{ name = "Johannes Soltwedel", email = "johannes_richard.soltwedel@tu-dresden.de" },
{ name = "Peter Sobolewski" },
]
keywords = ["OMERO.CLI", "plugin", "napari", "napari-plugin"]
classifiers = [
"Development Status :: 3 - Alpha",
"Development Status :: 4 - Beta",
"Environment :: X11 Applications :: Qt",
"Framework :: napari",
"Intended Audience :: Developers",
Expand All @@ -33,48 +36,49 @@ classifiers = [
"License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Topic :: Scientific/Engineering :: Information Analysis",
"Topic :: Scientific/Engineering :: Visualization",
"Topic :: Scientific/Engineering",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities",
# "License :: OSI Approved :: BSD License",
# "Typing :: Typed",
"License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
"Typing :: Typed",
]
# add your package dependencies here
dependencies = [
"napari>=0.4.13",
"omero-py",
"omero-rois",
"importlib-metadata; python_version < '3.8'",
# these come with napari ...
# but are directly imported here as well so are included explicitly
"qtpy>=1.10.0",
"dask[array]>=2021.10.0",
"vispy>=0.14.1,<0.15",
"superqt>=0.6.7",
]

# https://peps.python.org/pep-0621/#dependencies-optional-dependencies
# "extras" (e.g. for `pip install .[test]`)
[project.optional-dependencies]
all = ["napari[all]"]
# add dependencies used for testing here
test = [
"pytest",
"pytest-cov",
"pytest-qt",
"pytest-regressions",
"pywin32; sys_platform == 'win32'",
]
# add anything else you like to have in your dev environment here
dev = [
"black",
"napari-omero[all, test]",
"ipython",
"mypy",
"pdbpp", # https://github.com/pdbpp/pdbpp
"rich", # https://github.com/Textualize/rich
"pdbpp",
"pre-commit",
"rich",
"ruff",
]

Expand All @@ -91,34 +95,46 @@ napari-omero = "napari_omero.__main__:main"
[project.entry-points."napari.manifest"]
napari-omero = "napari_omero:napari.yaml"

# https://beta.ruff.rs/docs/rules/
# https://docs.astral.sh/ruff
[tool.ruff]
line-length = 88
target-version = "py37"
target-version = "py39"
src = ["src"]

# https://docs.astral.sh/ruff/rules
[tool.ruff.lint]
pydocstyle = { convention = "numpy" }
select = [
"E", # style errors
"W", # style warnings
"F", # flakes
"D", # pydocstyle
"D417", # Missing argument descriptions in Docstrings
"I", # isort
"UP", # pyupgrade
"C4", # flake8-comprehensions
"B", # flake8-bugbear
"A001", # flake8-builtins
"RUF", # ruff-specific rules
"TC", # flake8-type-checking
"TID", # flake8-tidy-imports
]
ignore = [
"D100", # Missing docstring in public module
"D107", # Missing docstring in __init__
"D203", # 1 blank line required before class docstring
"D212", # Multi-line docstring summary should start at the first line
"D213", # Multi-line docstring summary should start at the second line
"D401", # First line should be in imperative mood
"D413", # Missing blank line after last section
"D416", # Section name should end with a colon
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D103", # Missing docstring in public function
"D104", # Missing docstring in public package
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"tests/*.py" = ["D", "S"]
"setup.py" = ["D"]

# https://docs.astral.sh/ruff/formatter/
[tool.ruff.format]
docstring-code-format = true
skip-magic-trailing-comma = false # default is false

# https://mypy.readthedocs.io/en/stable/config_file.html
[tool.mypy]
Expand All @@ -134,7 +150,7 @@ pretty = true

# https://docs.pytest.org/en/6.2.x/customize.html
[tool.pytest.ini_options]
minversion = "6.0"
minversion = "7.0"
testpaths = ["tests"]
filterwarnings = [
"error",
Expand All @@ -155,6 +171,7 @@ exclude_lines = [
"except ImportError",
"\\.\\.\\.",
"raise NotImplementedError()",
"pass",
]
[tool.coverage.run]
source = ["src"]
Expand Down
5 changes: 1 addition & 4 deletions src/napari_omero/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
try:
from importlib.metadata import PackageNotFoundError, version
except ModuleNotFoundError:
from importlib_metadata import PackageNotFoundError, version # type: ignore
from importlib.metadata import PackageNotFoundError, version

try:
__version__ = version("napari-omero")
Expand Down
Loading

0 comments on commit 5ec1a5b

Please sign in to comment.