Skip to content

Commit 11c0bd8

Browse files
authored
Move to pyproject.toml (#3)
* Update pyproject.toml * Remove now-redundant files * Remove static cast version * Update CI workflow * Lint pass * Pre-commit config and lint pass * Fix un-edited optional dependency in tox.ini * Move tests to top-level structure * Tox should forget python 3.8 and test python 3.11 * Fix missing command in example
1 parent 42fa7d8 commit 11c0bd8

11 files changed

+157
-214
lines changed

.github/workflows/test_and_deploy.yml

+44-61
Original file line numberDiff line numberDiff line change
@@ -7,84 +7,67 @@ on:
77
push:
88
branches:
99
- main
10-
- npe2
1110
tags:
12-
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
11+
- "v**" # Push events to matching v*, i.e. v1.0, v20.15.10
1312
pull_request:
1413
branches:
15-
- main
16-
- npe2
14+
- "*"
1715
workflow_dispatch:
1816

17+
concurrency:
18+
# Cancel this workflow is it is running and changes are applied
19+
# to the HEAD of the branch, triggering another run of the
20+
# workflow
21+
group: ${{ github.workflow }}-${{ github.ref }}
22+
cancel-in-progress: true
23+
1924
jobs:
25+
linting:
26+
runs-on: ubuntu-latest
27+
name: Check Linting
28+
steps:
29+
- uses: neuroinformatics-unit/actions/lint@v2
30+
31+
manifest:
32+
runs-on: ubuntu-latest
33+
name: Check Manifest
34+
steps:
35+
- uses: neuroinformatics-unit/actions/check_manifest@v2
36+
2037
test:
21-
name: ${{ matrix.platform }} py${{ matrix.python-version }}
38+
needs: [linting, manifest]
39+
name: Run tests (${{ matrix.platform }} py${{ matrix.python-version }})
2240
runs-on: ${{ matrix.platform }}
2341
strategy:
2442
matrix:
2543
platform: [ubuntu-latest, windows-latest, macos-latest]
26-
python-version: ['3.8', '3.9', '3.10']
27-
44+
python-version: ["3.9", "3.10", "3.11"]
2845
steps:
29-
- uses: actions/checkout@v3
46+
- name: Setup qtpy libraries
47+
uses: tlambert03/setup-qt-libs@v1
3048

31-
- name: Set up Python ${{ matrix.python-version }}
32-
uses: actions/setup-python@v4
33-
with:
34-
python-version: ${{ matrix.python-version }}
35-
36-
# these libraries enable testing on Qt on linux
37-
- uses: tlambert03/setup-qt-libs@v1
38-
39-
# strategy borrowed from vispy for installing opengl libs on windows
40-
- name: Install Windows OpenGL
41-
if: runner.os == 'Windows'
42-
run: |
43-
git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git
44-
powershell gl-ci-helpers/appveyor/install_opengl.ps1
49+
- name: Setup VTK headless display
50+
uses: pyvista/setup-headless-display-action@v2
4551

46-
# note: if you need dependencies from conda, considering using
47-
# setup-miniconda: https://github.com/conda-incubator/setup-miniconda
48-
# and
49-
# tox-conda: https://github.com/tox-dev/tox-conda
50-
- name: Install dependencies
51-
run: |
52-
python -m pip install --upgrade pip
53-
python -m pip install setuptools tox tox-gh-actions
54-
55-
# this runs the platform-specific tests declared in tox.ini
56-
- name: Test with tox
57-
uses: aganders3/headless-gui@v1
52+
- name: Run unit tests
53+
uses: neuroinformatics-unit/actions/test@v2
5854
with:
59-
run: python -m tox
60-
env:
61-
PLATFORM: ${{ matrix.platform }}
62-
63-
- name: Coverage
64-
uses: codecov/codecov-action@v3
55+
python-version: ${{ matrix.python-version }}
56+
secret-codecov-token: ${{ secrets.CODECOV_TOKEN }}
6557

66-
deploy:
67-
# this will run when you have tagged a commit, starting with "v*"
68-
# and requires that you have put your twine API key in your
69-
# github secrets (see readme for details)
58+
build_sdist_wheel:
59+
name: Build source distribution wheel
7060
needs: [test]
61+
if: github.event_name == 'push' && github.ref_type == 'tag'
62+
runs-on: ubuntu-latest
63+
steps:
64+
- uses: neuroinformatics-unit/actions/build_sdist_wheels@v2
65+
66+
upload_all:
67+
name: Publish to PyPI
68+
needs: [build_sdist_wheel]
7169
runs-on: ubuntu-latest
72-
if: contains(github.ref, 'tags')
7370
steps:
74-
- uses: actions/checkout@v3
75-
- name: Set up Python
76-
uses: actions/setup-python@v4
71+
- uses: neuroinformatics-unit/actions/upload_pypi@v2
7772
with:
78-
python-version: "3.x"
79-
- name: Install dependencies
80-
run: |
81-
python -m pip install --upgrade pip
82-
pip install -U setuptools setuptools_scm wheel twine build
83-
- name: Build and publish
84-
env:
85-
TWINE_USERNAME: __token__
86-
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
87-
run: |
88-
git tag
89-
python -m build .
90-
twine upload dist/*
73+
secret-pypi-key: ${{ secrets.TWINE_API_KEY }}

.pre-commit-config.yaml

+17-11
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
1+
ci:
2+
autoupdate_schedule: monthly
3+
14
repos:
25
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.5.0
6+
rev: v4.6.0
47
hooks:
58
- id: check-docstring-first
9+
- id: check-merge-conflict
10+
- id: check-toml
11+
- id: check-yaml # checks for correct yaml syntax for github actions ex.
612
- id: end-of-file-fixer
13+
- id: mixed-line-ending
14+
args: [--fix=lf]
715
- id: trailing-whitespace
816
exclude: ^\.napari-hub/.*
9-
- id: check-yaml # checks for correct yaml syntax for github actions ex.
10-
- repo: https://github.com/charliermarsh/ruff-pre-commit
11-
rev: v0.1.14
17+
- repo: https://github.com/mgedmin/check-manifest
18+
rev: "0.49"
19+
hooks:
20+
- id: check-manifest
21+
- repo: https://github.com/astral-sh/ruff-pre-commit
22+
rev: v0.4.8
1223
hooks:
1324
- id: ruff
25+
args: [ --fix ]
1426
- repo: https://github.com/psf/black
15-
rev: 23.12.1
27+
rev: 24.4.2
1628
hooks:
1729
- id: black
1830
- repo: https://github.com/tlambert03/napari-plugin-checks
1931
rev: v0.3.0
2032
hooks:
2133
- id: napari-plugin-checks
22-
# https://mypy.readthedocs.io/en/stable/introduction.html
23-
# you may wish to add this as well!
24-
# - repo: https://github.com/pre-commit/mirrors-mypy
25-
# rev: v0.910-1
26-
# hooks:
27-
# - id: mypy

MANIFEST.in

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
include LICENSE
22
include README.md
33

4+
exclude .pre-commit-config.yaml
5+
46
recursive-exclude * __pycache__
57
recursive-exclude * *.py[co]
8+
9+
prune .napari-hub
10+
prune tests

pyproject.toml

+87-44
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,99 @@
1+
[project]
2+
name = "napari-experimental"
3+
description = "A place to experiment with core-independent features without breaking core napari"
4+
readme = "README.md"
5+
license = { file = "LICENSE" }
6+
authors = [{ name = "Alessandro Felder", email = "[email protected]" }]
7+
classifiers = [
8+
"Development Status :: 2 - Pre-Alpha",
9+
"Framework :: napari",
10+
"Intended Audience :: Developers",
11+
"License :: OSI Approved :: BSD License",
12+
"Operating System :: OS Independent",
13+
"Programming Language :: Python",
14+
"Programming Language :: Python :: 3",
15+
"Programming Language :: Python :: 3 :: Only",
16+
"Programming Language :: Python :: 3.8",
17+
"Programming Language :: Python :: 3.9",
18+
"Programming Language :: Python :: 3.10",
19+
"Topic :: Scientific/Engineering :: Image Processing",
20+
]
21+
requires-python = ">=3.9"
22+
dependencies = ["numpy", "napari", "magicgui", "pyqt5", "qtpy", "scikit-image"]
23+
dynamic = ["version"]
24+
25+
[project.entry-points."napari.manifest"]
26+
napari-experimental = "napari_experimental:napari.yaml"
27+
28+
[project.optional-dependencies]
29+
dev = ["tox", "pytest", "pytest-cov", "pytest-qt"]
30+
31+
[project.urls]
32+
"Bug Tracker" = "https://github.com/alessandrofelder/napari-experimental/issues"
33+
"Documentation" = "https://github.com/alessandrofelder/napari-experimental#README.md"
34+
"Source Code" = "https://github.com/alessandrofelder/napari-experimental"
35+
"User Support" = "https://github.com/alessandrofelder/napari-experimental/issues"
36+
137
[build-system]
2-
requires = ["setuptools>=42.0.0", "wheel"]
38+
requires = ["setuptools>=42.0.0", "setuptools_scm", "wheel"]
339
build-backend = "setuptools.build_meta"
440

41+
[tool.setuptools]
42+
include-package-data = true
43+
44+
[tool.setuptools.packages.find]
45+
where = ["src"]
46+
include = ["napari_experimental*"]
47+
namespaces = false
548

49+
[tool.setuptools.package-data]
50+
napari_experimental = ["*.yaml"]
51+
52+
[tool.setuptools_scm]
653

754
[tool.black]
855
line-length = 79
9-
target-version = ['py38', 'py39', 'py310']
10-
56+
skip-string-normalization = false
57+
target-version = ["py39", "py310", "py311"]
1158

1259
[tool.ruff]
60+
exclude = ["__init__.py", "build", ".eggs"]
1361
line-length = 79
14-
select = [
15-
"E", "F", "W", #flake8
16-
"UP", # pyupgrade
17-
"I", # isort
18-
"BLE", # flake8-blind-exception
19-
"B", # flake8-bugbear
20-
"A", # flake8-builtins
21-
"C4", # flake8-comprehensions
22-
"ISC", # flake8-implicit-str-concat
23-
"G", # flake8-logging-format
24-
"PIE", # flake8-pie
25-
"SIM", # flake8-simplify
26-
]
27-
ignore = [
28-
"E501", # line too long. let black handle this
29-
"UP006", "UP007", # type annotation. As using magicgui require runtime type annotation then we disable this.
30-
"SIM117", # flake8-simplify - some of merged with statements are not looking great with black, reanble after drop python 3.9
31-
]
62+
lint.select = ["I", "E", "F", "B"]
63+
target-version = "py311"
64+
fix = true
3265

33-
exclude = [
34-
".bzr",
35-
".direnv",
36-
".eggs",
37-
".git",
38-
".mypy_cache",
39-
".pants.d",
40-
".ruff_cache",
41-
".svn",
42-
".tox",
43-
".venv",
44-
"__pypackages__",
45-
"_build",
46-
"buck-out",
47-
"build",
48-
"dist",
49-
"node_modules",
50-
"venv",
51-
"*vendored*",
52-
"*_vendor*",
53-
]
66+
[tool.tox]
67+
legacy_tox_ini = """
68+
[tox]
69+
envlist = py{39,310,311}-{linux,macos,windows}
70+
isolated_build=true
5471
55-
target-version = "py38"
56-
fix = true
72+
[gh-actions]
73+
python =
74+
3.9: py39
75+
3.10: py310
76+
3.11: py3.11
77+
78+
[gh-actions:env]
79+
PLATFORM =
80+
ubuntu-latest: linux
81+
macos-latest: macos
82+
windows-latest: windows
83+
84+
[testenv]
85+
platform =
86+
macos: darwin
87+
linux: linux
88+
windows: win32
89+
passenv =
90+
CI
91+
GITHUB_ACTIONS
92+
DISPLAY
93+
XAUTHORITY
94+
NUMPY_EXPERIMENTAL_ARRAY_FUNCTION
95+
PYVISTA_OFF_SCREEN
96+
extras =
97+
dev
98+
commands = pytest -v --color=yes --cov=napari_experimental --cov-report=xml
99+
"""

setup.cfg

-64
This file was deleted.

src/napari_experimental/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
__version__ = "0.0.1"
21
from ._widget import (
32
ExampleQWidget,
43
ImageThreshold,

0 commit comments

Comments
 (0)