diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 27ecdc8..c1b12b1 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -12,6 +12,14 @@ on: workflow_dispatch: jobs: + check-manifest: + name: Check Manifest + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - run: pip install check-manifest && check-manifest + # Won't work without GPU # test: @@ -54,25 +62,36 @@ jobs: # - name: Coverage # uses: codecov/codecov-action@v1 + deploy: - # needs: test + name: Deploy + needs: check-manifest + if: "success() && startsWith(github.ref, 'refs/tags/')" runs-on: ubuntu-latest - if: ${{ github.repository == 'tlambert03/pycudadecon' && contains(github.ref, 'tags') }} + steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: "3.x" - - name: Install dependencies + + - name: install run: | - python -m pip install --upgrade pip - pip install -U setuptools wheel twine + git tag + pip install -U pip + pip install -U build twine + python -m build + twine check dist/* + ls -lh dist + - name: Build and publish + run: twine upload dist/* env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} - run: | - git tag - python setup.py sdist bdist_wheel - twine upload dist/* + + - uses: softprops/action-gh-release@v1 + with: + generate_release_notes: true \ No newline at end of file diff --git a/pycudadecon/__init__.py b/pycudadecon/__init__.py index 945c97d..c758569 100755 --- a/pycudadecon/__init__.py +++ b/pycudadecon/__init__.py @@ -1,4 +1,13 @@ -__version__ = "0.2.0" +try: + from importlib.metadata import PackageNotFoundError, version +except ImportError: + from importlib_metadata import PackageNotFoundError, version + +try: + __version__ = version("pycudadecon") +except PackageNotFoundError: + __version__ = "uninstalled" + from typing import Any lib: Any diff --git a/pycudadecon/napari.py b/pycudadecon/napari.py index 9070017..e932d3e 100644 --- a/pycudadecon/napari.py +++ b/pycudadecon/napari.py @@ -1,28 +1,44 @@ -""" -This module is an example of a barebones QWidget plugin for napari +from typing import TYPE_CHECKING -It implements the ``napari_experimental_provide_dock_widget`` hook specification. -see: https://napari.org/docs/dev/plugins/hook_specifications.html +if TYPE_CHECKING: + import napari.types -Replace code below according to your needs. -""" -from magicgui import magic_factory -from napari_plugin_engine import napari_hook_implementation -from napari.types import ImageData -from pycudadecon.deconvolution import decon - - -@magic_factory(call_button="Deconvolve") def deconvolve( - image: ImageData, - psf: ImageData, + image: "napari.types.ImageData", + psf: "napari.types.ImageData", image_pixel_size=0.1, image_zstep=0.5, psf_pixel_size=0.1, psf_zstep=0.1, iterations=10, -) -> ImageData: +) -> "napari.types.ImageData": + """Deconvolve `image` using `psf`. + + Parameters + ---------- + image : ImageData + image array + psf : ImageData + psf array + image_pixel_size : float, optional + image pixel size in microns, by default 0.1 + image_zstep : float, optional + image z step in microns, by default 0.5 + psf_pixel_size : float, optional + psf pixel size in microns, by default 0.1 + psf_zstep : float, optional + psf z step size in microns, by default 0.1 + iterations : int, optional + number of iterations, by default 10 + + Returns + ------- + ImageData + deconvolved image. + """ + from pycudadecon.deconvolution import decon + return decon( image, psf, @@ -32,9 +48,3 @@ def deconvolve( dzpsf=psf_zstep, n_iters=iterations, ) - - -@napari_hook_implementation -def napari_experimental_provide_dock_widget(): - # you can return either a single widget, or a sequence of widgets - return deconvolve, {"name": "CUDA-Deconvolution"} diff --git a/pycudadecon/napari.yaml b/pycudadecon/napari.yaml new file mode 100644 index 0000000..9137219 --- /dev/null +++ b/pycudadecon/napari.yaml @@ -0,0 +1,11 @@ +name: pycudadecon +display_name: pyCUDAdecon +contributions: + commands: + - id: pycudadecon.deconvolve + python_name: pycudadecon.napari:deconvolve + title: Deconvolve + widgets: + - command: pycudadecon.deconvolve + display_name: CUDA-Deconvolution + autogenerate: True diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..eab9dc8 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,14 @@ +[build-system] +requires = ["setuptools>=45", "wheel", "setuptools-scm>=6.2"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] + +[tool.check-manifest] +ignore = [ + ".pre-commit-config.yaml", + "test/**/*", + "docs/**/*", + "examples/**/*", + "CHANGELOG.md", +] diff --git a/setup.cfg b/setup.cfg index 94a076e..fe0d1fa 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,5 @@ [metadata] name = pycudadecon -version = 0.2.0 description = Python wrapper for CUDA-accelerated 3D deconvolution long_description = file: README.md long_description_content_type = text/markdown @@ -35,15 +34,21 @@ project_urls = [options] packages = find: +include_package_data = True install_requires = numpy tifffile typing_extensions + importlib-metadata;python_version<'3.8' python_requires = >=3.6 [options.entry_points] -napari.plugin = - pycudadecon = pycudadecon.napari +napari.manifest = + pycudadecon = pycudadecon:napari.yaml + +[options.package_data] +* = *.yaml + [options.extras_require] dev =