From 49742e488be7f7e8f1f03636caaa7ad0e4773f22 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Fri, 22 Jul 2022 15:32:04 -0400 Subject: [PATCH 01/13] convert to pyproject --- .gitignore | 2 +- .pre-commit-config.yaml | 42 +++++++++++ MANIFEST.in | 10 --- Makefile | 4 -- pyproject.toml | 149 ++++++++++++++++++++++++++++++++++++++++ setup.cfg | 42 ++--------- setup.py | 117 ++----------------------------- tox.ini | 20 ------ 8 files changed, 201 insertions(+), 185 deletions(-) create mode 100644 .pre-commit-config.yaml delete mode 100644 MANIFEST.in create mode 100644 pyproject.toml delete mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index b48d2cb..40f17b7 100644 --- a/.gitignore +++ b/.gitignore @@ -117,4 +117,4 @@ workbench.ipynb # Ignore test resources directory resources/ -writer_products/ \ No newline at end of file +writer_products/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..5f17f54 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,42 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: check-docstring-first + - id: end-of-file-fixer + - id: trailing-whitespace + + - repo: https://github.com/PyCQA/isort + rev: 5.10.1 + hooks: + - id: isort + + - repo: https://github.com/myint/autoflake + rev: v1.4 + hooks: + - id: autoflake + args: ["--in-place", "--remove-all-unused-imports"] + + - repo: https://github.com/psf/black + rev: 22.6.0 + hooks: + - id: black + + - repo: https://github.com/PyCQA/flake8 + rev: 4.0.1 + hooks: + - id: flake8 + additional_dependencies: + - flake8-typing-imports>=1.9.0 + - flake8-pyprojecttoml + args: ["--min-python-version=3.8.0"] + + - repo: https://github.com/tlambert03/napari-plugin-checks + rev: v0.2.0 + hooks: + - id: napari-plugin-checks + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.971 + hooks: + - id: mypy diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index b03e86e..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,10 +0,0 @@ -include CONTRIBUTING.md -include LICENSE -include README.md - -recursive-include tests * -recursive-exclude * __pycache__ -recursive-exclude * *.py[co] - -recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif -graft napari_aicsimageio/data diff --git a/Makefile b/Makefile index 9e86522..cb4a49d 100644 --- a/Makefile +++ b/Makefile @@ -25,11 +25,7 @@ clean: ## clean all build, python, and testing files find . -name '*.pyo' -exec rm -fr {} + find . -name '*~' -exec rm -fr {} + find . -name '__pycache__' -exec rm -fr {} + - rm -fr .tox/ rm -fr .coverage rm -fr coverage.xml rm -fr htmlcov/ rm -fr .pytest_cache - -build: ## run tox / run tests and lint - tox \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..47f3d03 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,149 @@ +# https://peps.python.org/pep-0517/ +[build-system] +requires = ["setuptools>=45", "wheel", "setuptools-scm>=6.2"] +build-backend = "setuptools.build_meta" + + +# https://peps.python.org/pep-0621/ +[project] +name = "napari-aicsimageio" +# Do not edit this string manually, always use bumpversion +# Details in CONTRIBUTING.rst +version = "0.7.0" +description = "AICSImageIO bindings for napari" +keywords = [ + "aicsimageio", + "CZI", + "image reading", + "imageio", + "LIF", + "metadata", + "napari", + "ND2", + "TIFF", +] +readme = "README.md" +requires-python = ">=3.8" +license = { text = "GPLv3" } +authors = [ + { email = "evamaxfieldbrown@gmail.com", name = "Eva Maxfield Brown" }, + { email = "talley.lambert@gmail.com", name = "Talley Lambert" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Science/Research", + "Framework :: napari", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Topic :: Scientific/Engineering :: Bio-Informatics", + "Topic :: Scientific/Engineering :: Image Processing", + "Topic :: Scientific/Engineering :: Information Analysis", + "Topic :: Scientific/Engineering :: Visualization", + "Topic :: Scientific/Engineering", +] +dynamic = [] +dependencies = [ + "aicsimageio[all]>=4.6.3", + "fsspec[http]", # no version pin, we pull from aicsimageio + "napari>=0.4.11", + "psutil>=5.7.0", + # Formats not included by default with aicsimageio + "aicspylibczi>=3.0.5", + "bioformats_jar", + "readlif>=0.6.4", +] + +[project.urls] +Homepage = "https://github.com/AllenCellModeling/napari-aicsimageio" +"Bug Tracker" = "https://github.com/AllenCellModeling/napari-aicsimageio/issues" +Documentation = "https://github.com/AllenCellModeling/napari-aicsimageio#README.md" +"User Support" = "https://github.com/AllenCellModeling/napari-aicsimageio/issues" + +# extras +# https://peps.python.org/pep-0621/#dependencies-optional-dependencies +[project.optional-dependencies] +test = [ + "PyQt5", + "pytest>=5.4.3", + "pytest-qt~=4.0", + "pytest-cov>=2.9.0", + "pytest-raises>=0.11", + "pytest-xvfb~=2.0", + "quilt3~=3.4.0", +] +dev = [ + "black>=19.10b0", + "bump2version>=1.0.1", + "coverage>=5.1", + "docutils>=0.10,<0.16", + "flake8-debugger>=3.2.1", + "flake8-pyprojecttoml", + "flake8>=3.8.3", + "ipython>=7.15.0", + "isort>=5.7.0", + "mypy>=0.800", + "pytest-runner>=5.2", + "twine>=3.1.1", + "wheel>=0.34.2", +] + +# Entry points +# https://peps.python.org/pep-0621/#entry-points +[project.entry-points."napari.manifest"] +napari-aicsimageio = "napari_aicsimageio:napari.yaml" + +# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html +[tool.setuptools] +zip-safe = false +include-package-data = true +packages = { find = { exclude = ["tests", "*.tests", "*.tests.*"] } } + +[tool.setuptools.package-data] +"*" = ["*.yaml"] + +[tool.black] +line-length = 79 + +[tool.isort] +ensure_newline_before_comments = true +force_grid_wrap = 0 +include_trailing_comma = true +line_length = 88 +multi_line_output = 3 +profile = "black" +use_parentheses = true + +# https://github.com/mgedmin/check-manifest#configuration +[tool.check-manifest] +ignore = [ + ".napari/**/*", + ".pre-commit-config.yaml", +] + +# https://docs.pytest.org/en/6.2.x/customize.html +[tool.pytest.ini_options] +minversion = "6.0" +xfail_strict = true +filterwarnings = [ + "error:::napari_aicsimageio", # make all internal warnings errors (test them directly) + "ignore:distutils Version classes are deprecated:", +] + +[too.mypy] +ignore_missing_imports = true +disallow_untyped_defs = true +check_untyped_defs = true + + +# https://flake8.pycqa.org/en/latest/user/options.html +# https://gitlab.com/durko/flake8-pyprojecttoml +[tool.flake8] +exclude = "docs/,napari_aicsimageio/vendor/" +max-line-length = 88 +ignore = "E203,E402,W291,W503" +min-python-version = "3.8.0" +per-file-ignores = [] diff --git a/setup.cfg b/setup.cfg index 6181fc1..f9dbbaf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,7 @@ +# could remove this file if we migrated away from bumpversion + +# https://github.com/c4urself/bump2version/issues/42 +# :( [bumpversion] current_version = 0.7.0 parse = (?P\d+)\.(?P\d+)\.(?P\d+) @@ -12,41 +16,3 @@ replace = version="{new_version}" [bumpversion:file:napari_aicsimageio/__init__.py] search = {current_version} replace = {new_version} - -[bdist_wheel] -universal = 1 - -[aliases] -test = pytest - -[tool:pytest] -collect_ignore = ['setup.py'] -xfail_strict = true -filterwarnings = - ignore::UserWarning - ignore::FutureWarning - ignore:distutils Version classes are deprecated: - -[flake8] -exclude = - docs/ - napari_aicsimageio/vendor/ -ignore = - E203 - E402 - W291 - W503 -max-line-length = 88 - -[isort] -multi_line_output = 3 -include_trailing_comma = True -force_grid_wrap = 0 -use_parentheses = True -ensure_newline_before_comments = True -line_length = 88 - -[mypy] -ignore_missing_imports = True -disallow_untyped_defs = True -check_untyped_defs = True diff --git a/setup.py b/setup.py index 9fb3aa4..9ae5cfa 100644 --- a/setup.py +++ b/setup.py @@ -1,113 +1,6 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +# This file is only needed for editable installs (using pyproject.toml) +# until setuptools implements PEP 660 +# https://github.com/pypa/setuptools/issues/2816 +import setuptools -"""The setup script.""" - -from setuptools import find_packages, setup - -with open("README.md") as readme_file: - readme = readme_file.read() - -setup_requirements = [ - "pytest-runner>=5.2", -] - -test_requirements = [ - "black>=19.10b0", - "codecov>=2.1.4", - "docutils>=0.10,<0.16", - "flake8>=3.8.3", - "flake8-debugger>=3.2.1", - "isort>=5.7.0", - "mypy>=0.800", - "napari[pyqt]", - "psutil>=5.7.0", - "pytest>=5.4.3", - "pytest-qt~=4.0", - "pytest-cov>=2.9.0", - "pytest-raises>=0.11", - "pytest-xvfb~=2.0", - "quilt3~=3.4.0", -] - -dev_requirements = [ - *setup_requirements, - *test_requirements, - "bump2version>=1.0.1", - "coverage>=5.1", - "ipython>=7.15.0", - "pytest-runner>=5.2", - "tox>=3.15.2", - "twine>=3.1.1", - "wheel>=0.34.2", -] - -requirements = [ - "aicsimageio[all]>=4.6.3", - "fsspec[http]", # no version pin, we pull from aicsimageio - "napari>=0.4.11", - "psutil>=5.7.0", - # Formats not included by default with aicsimageio - "aicspylibczi>=3.0.5", - "bioformats_jar", - "readlif>=0.6.4", -] - -extra_requirements = { - "setup": setup_requirements, - "test": test_requirements, - "dev": dev_requirements, -} - -setup( - author="Eva Maxfield Brown", - author_email="evamaxfieldbrown@gmail.com", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Science/Research", - "Framework :: napari", - "Topic :: Scientific/Engineering", - "Topic :: Scientific/Engineering :: Visualization", - "Topic :: Scientific/Engineering :: Information Analysis", - "Topic :: Scientific/Engineering :: Bio-Informatics", - "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", - "Natural Language :: English", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Operating System :: OS Independent", - ], - description=( - "AICSImageIO for napari. " - "Multiple file format reading directly into napari using pure Python." - ), - entry_points={ - "napari.manifest": [ - "napari-aicsimageio = napari_aicsimageio:napari.yaml", - ], - }, - install_requires=requirements, - license="GPLv3", - long_description=readme, - long_description_content_type="text/markdown", - include_package_data=True, - keywords="napari, aicsimageio, TIFF, CZI, LIF, imageio, image reading, metadata", - name="napari-aicsimageio", - packages=find_packages(exclude=["tests", "*.tests", "*.tests.*"]), - package_data={"napari_aicsimageio": ["napari.yaml"]}, - python_requires=">=3.8", - setup_requires=setup_requirements, - test_suite="napari_aicsimageio/tests", - tests_require=test_requirements, - extras_require=extra_requirements, - url="https://github.com/AllenCellModeling/napari-aicsimageio", - project_urls={ - "Source Code": "https://github.com/AllenCellModeling/napari-aicsimageio", - "Bug Tracker": "https://github.com/AllenCellModeling/napari-aicsimageio/issues", - "Documentation": "https://github.com/AllenCellModeling/napari-aicsimageio#README.md", - "User Support": "https://github.com/AllenCellModeling/napari-aicsimageio/issues", - }, - # Do not edit this string manually, always use bumpversion - # Details in CONTRIBUTING.rst - version="0.7.0", - zip_safe=False, -) +setuptools.setup() diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 98c4577..0000000 --- a/tox.ini +++ /dev/null @@ -1,20 +0,0 @@ -[tox] -skipsdist = True -envlist = py38, py39, lint - -[testenv:lint] -deps = - .[test] -commands = - flake8 napari_aicsimageio --count --verbose --show-source --statistics - isort napari_aicsimageio --check-only - mypy napari_aicsimageio - black --check napari_aicsimageio - -[testenv] -setenv = - PYTHONPATH = {toxinidir} -deps = - .[test] -commands = - pytest --basetemp={envtmpdir} --cov-report html --cov=napari_aicsimageio napari_aicsimageio/tests/ \ No newline at end of file From f5a5d2d54787c1ecb82dc3112cdd47a9a45e55e0 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Fri, 22 Jul 2022 15:41:35 -0400 Subject: [PATCH 02/13] update tests --- .github/dependabot.yml | 10 +++++ .github/workflows/build-main.yml | 61 +++++++++++++------------ .github/workflows/test-and-lint.yml | 70 ----------------------------- .pre-commit-config.yaml | 6 --- 4 files changed, 40 insertions(+), 107 deletions(-) create mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/test-and-lint.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..8b0becb --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + commit-message: + prefix: "ci(dependabot):" diff --git a/.github/workflows/build-main.yml b/.github/workflows/build-main.yml index acad452..0522fa5 100644 --- a/.github/workflows/build-main.yml +++ b/.github/workflows/build-main.yml @@ -4,30 +4,34 @@ on: push: branches: - main - schedule: - # - # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07 - # Run every Monday at 18:00:00 UTC (Monday at 10:00:00 PST) - - cron: "0 18 * * 1" + pull_request: + branches: + - main + workflow_dispatch: jobs: + check-manifest: + name: Check Manifest + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.x" + - run: pip install check-manifest && check-manifest + test: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - python-version: [3.8, 3.9] - os: [ - ubuntu-18.04, - ubuntu-20.04, - windows-latest, - macOS-10.15, - ] + python-version: [3.8, 3.9, "3.10"] + os: [ubuntu-latest, windows-latest, macos-latest] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} # Install qt support libs @@ -55,48 +59,43 @@ jobs: with: run: python -m pytest --cov-report xml --cov=napari_aicsimageio napari_aicsimageio/tests/ - name: Upload codecov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: 3.9 - name: Install Dependencies run: | python -m pip install --upgrade pip - pip install .[test] - - name: Lint with flake8 - run: | - flake8 napari_aicsimageio --count --verbose --show-source --statistics - isort napari_aicsimageio --check-only - mypy napari_aicsimageio - black --check --exclude vendor napari_aicsimageio + pip install pre-commit + - name: Lint with pre-commit + run: pre-commit run --all-files publish: if: "contains(github.event.head_commit.message, 'Bump version')" - needs: [test, lint] + needs: [check-manifest, test, lint] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: 3.9 - name: Install Dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel + pip install build wheel - name: Build Package - run: | - python setup.py sdist bdist_wheel + run: python -m build - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1 with: user: aicspypi password: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/test-and-lint.yml b/.github/workflows/test-and-lint.yml deleted file mode 100644 index fa39362..0000000 --- a/.github/workflows/test-and-lint.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: Test and Lint - -on: pull_request - -jobs: - test: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - python-version: [3.8, 3.9] - os: [ - ubuntu-18.04, - ubuntu-20.04, - windows-latest, - macOS-10.15, - ] - - steps: - - uses: actions/checkout@v1 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - # Install qt support libs - - uses: tlambert03/setup-qt-libs@v1 - - # strategy borrowed from vispy for installing opengl libs on windows - - 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 - if (Test-Path -Path "C:\Windows\system32\opengl32.dll" -PathType Leaf) {Exit 0} else {Exit 1} - - - name: Install Dependencies - run: | - python -m pip install --upgrade pip - pip install .[test] - - - name: Download Test Resources - run: | - python scripts/download_test_resources.py - - - name: Test with pytest - uses: GabrielBB/xvfb-action@v1 - with: - run: python -m pytest --cov-report xml --cov=napari_aicsimageio napari_aicsimageio/tests/ - - name: Upload codecov - uses: codecov/codecov-action@v1 - - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: 3.9 - - name: Install Dependencies - run: | - python -m pip install --upgrade pip - pip install .[test] - - name: Lint with flake8 - run: | - flake8 napari_aicsimageio --count --verbose --show-source --statistics - isort napari_aicsimageio --check-only - mypy napari_aicsimageio - black --check --exclude vendor napari_aicsimageio diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5f17f54..17a3f9f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,4 @@ repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 - hooks: - - id: check-docstring-first - - id: end-of-file-fixer - - id: trailing-whitespace - repo: https://github.com/PyCQA/isort rev: 5.10.1 From 02bef79dfe434e0b00c09e9e441cf63b4491df21 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Fri, 22 Jul 2022 15:43:16 -0400 Subject: [PATCH 03/13] update pyproject --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 47f3d03..7a7c866 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -106,7 +106,7 @@ packages = { find = { exclude = ["tests", "*.tests", "*.tests.*"] } } "*" = ["*.yaml"] [tool.black] -line-length = 79 +line-length = 88 [tool.isort] ensure_newline_before_comments = true @@ -142,7 +142,7 @@ check_untyped_defs = true # https://flake8.pycqa.org/en/latest/user/options.html # https://gitlab.com/durko/flake8-pyprojecttoml [tool.flake8] -exclude = "docs/,napari_aicsimageio/vendor/" +exclude = "scripts/**" max-line-length = 88 ignore = "E203,E402,W291,W503" min-python-version = "3.8.0" From 79ede1ad4adf62900901eabade1863cc283d40d4 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Fri, 22 Jul 2022 16:09:11 -0400 Subject: [PATCH 04/13] working build --- setup.cfg => .bumpversion.cfg | 2 -- .gitignore | 2 +- napari_aicsimageio/tests/__init__.py | 3 --- pyproject.toml | 17 ++++++++++++----- 4 files changed, 13 insertions(+), 11 deletions(-) rename setup.cfg => .bumpversion.cfg (86%) delete mode 100644 napari_aicsimageio/tests/__init__.py diff --git a/setup.cfg b/.bumpversion.cfg similarity index 86% rename from setup.cfg rename to .bumpversion.cfg index f9dbbaf..01df58c 100644 --- a/setup.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,3 @@ -# could remove this file if we migrated away from bumpversion - # https://github.com/c4urself/bump2version/issues/42 # :( [bumpversion] diff --git a/.gitignore b/.gitignore index 40f17b7..d0d1eef 100644 --- a/.gitignore +++ b/.gitignore @@ -116,5 +116,5 @@ ENV/ workbench.ipynb # Ignore test resources directory -resources/ +*/tests/resources/ writer_products/ diff --git a/napari_aicsimageio/tests/__init__.py b/napari_aicsimageio/tests/__init__.py deleted file mode 100644 index 7765e7e..0000000 --- a/napari_aicsimageio/tests/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# -*- coding: utf-8 -*- - -"""Unit test package for napari_aicsimageio.""" diff --git a/pyproject.toml b/pyproject.toml index 7a7c866..1b7af26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,8 @@ # https://peps.python.org/pep-0517/ [build-system] -requires = ["setuptools>=45", "wheel", "setuptools-scm>=6.2"] +requires = ["setuptools>=45", "wheel"] build-backend = "setuptools.build_meta" - # https://peps.python.org/pep-0621/ [project] name = "napari-aicsimageio" @@ -100,7 +99,7 @@ napari-aicsimageio = "napari_aicsimageio:napari.yaml" [tool.setuptools] zip-safe = false include-package-data = true -packages = { find = { exclude = ["tests", "*.tests", "*.tests.*"] } } +packages = { find = { exclude = ['scripts'] } } [tool.setuptools.package-data] "*" = ["*.yaml"] @@ -120,8 +119,16 @@ use_parentheses = true # https://github.com/mgedmin/check-manifest#configuration [tool.check-manifest] ignore = [ + ".bumpversion.cfg", + ".editorconfig", ".napari/**/*", ".pre-commit-config.yaml", + "CODE_OF_CONDUCT.md", + "codecov.yml", + "CONTRIBUTING.md", + "images/**/*", + "Makefile", + "scripts/**/*", ] # https://docs.pytest.org/en/6.2.x/customize.html @@ -129,8 +136,8 @@ ignore = [ minversion = "6.0" xfail_strict = true filterwarnings = [ - "error:::napari_aicsimageio", # make all internal warnings errors (test them directly) - "ignore:distutils Version classes are deprecated:", + "error:::napari_aicsimageio", # make all internal warnings errors (test them directly) + "ignore:distutils Version classes are deprecated:", ] [too.mypy] From c6bdb6d0d1c3f1ae867c0a16e6a9f64aa5d0f791 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Fri, 22 Jul 2022 16:15:17 -0400 Subject: [PATCH 05/13] update test run line --- .github/workflows/build-main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-main.yml b/.github/workflows/build-main.yml index 0522fa5..33edb36 100644 --- a/.github/workflows/build-main.yml +++ b/.github/workflows/build-main.yml @@ -57,7 +57,7 @@ jobs: - name: Test with pytest uses: GabrielBB/xvfb-action@v1 with: - run: python -m pytest --cov-report xml --cov=napari_aicsimageio napari_aicsimageio/tests/ + run: python -m pytest --cov-report=xml --cov=napari_aicsimageio - name: Upload codecov uses: codecov/codecov-action@v3 From 10a79e2020fdbeaded6827ad6f4923d8af801987 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Fri, 22 Jul 2022 16:27:30 -0400 Subject: [PATCH 06/13] rename build main --- .github/workflows/build-main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-main.yml b/.github/workflows/build-main.yml index 33edb36..8f0fc85 100644 --- a/.github/workflows/build-main.yml +++ b/.github/workflows/build-main.yml @@ -1,4 +1,4 @@ -name: Build Main +name: CI on: push: From 1012c03b3394a9e02d562939a2699b340985523a Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sun, 24 Jul 2022 13:52:14 -0400 Subject: [PATCH 07/13] fix typo --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1b7af26..faf0f26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -140,7 +140,7 @@ filterwarnings = [ "ignore:distutils Version classes are deprecated:", ] -[too.mypy] +[tool.mypy] ignore_missing_imports = true disallow_untyped_defs = true check_untyped_defs = true From 8c31339d4cf564878230996162191b8394222c41 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sun, 24 Jul 2022 14:17:00 -0400 Subject: [PATCH 08/13] update lint --- .pre-commit-config.yaml | 3 ++- pyproject.toml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 17a3f9f..d76a03c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,6 @@ repos: additional_dependencies: - flake8-typing-imports>=1.9.0 - flake8-pyprojecttoml - args: ["--min-python-version=3.8.0"] - repo: https://github.com/tlambert03/napari-plugin-checks rev: v0.2.0 @@ -34,3 +33,5 @@ repos: rev: v0.971 hooks: - id: mypy + exclude: scripts + diff --git a/pyproject.toml b/pyproject.toml index faf0f26..0584935 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -141,10 +141,11 @@ filterwarnings = [ ] [tool.mypy] +files = "napari_aicsimageio/*.py" ignore_missing_imports = true disallow_untyped_defs = true check_untyped_defs = true - +show_error_codes = true # https://flake8.pycqa.org/en/latest/user/options.html # https://gitlab.com/durko/flake8-pyprojecttoml From d9b6f1c7307cf3cc901ba194666c152908307563 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sun, 24 Jul 2022 14:29:15 -0400 Subject: [PATCH 09/13] build/use-setuptools-scm-for-versioning --- .bumpversion.cfg | 16 ---------------- .github/workflows/build-main.yml | 5 ++++- CONTRIBUTING.md | 14 ++++++++------ napari_aicsimageio/__init__.py | 11 +++++++---- pyproject.toml | 11 ++++------- 5 files changed, 23 insertions(+), 34 deletions(-) delete mode 100644 .bumpversion.cfg diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index 01df58c..0000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,16 +0,0 @@ -# https://github.com/c4urself/bump2version/issues/42 -# :( -[bumpversion] -current_version = 0.7.0 -parse = (?P\d+)\.(?P\d+)\.(?P\d+) -serialize = {major}.{minor}.{patch} -commit = True -tag = True - -[bumpversion:file:setup.py] -search = version="{current_version}" -replace = version="{new_version}" - -[bumpversion:file:napari_aicsimageio/__init__.py] -search = {current_version} -replace = {new_version} diff --git a/.github/workflows/build-main.yml b/.github/workflows/build-main.yml index 8f0fc85..fb66dc8 100644 --- a/.github/workflows/build-main.yml +++ b/.github/workflows/build-main.yml @@ -4,6 +4,8 @@ on: push: branches: - main + tags: + - "v*" pull_request: branches: - main @@ -78,7 +80,7 @@ jobs: run: pre-commit run --all-files publish: - if: "contains(github.event.head_commit.message, 'Bump version')" + if: "success() && startsWith(github.ref, 'refs/tags/')" needs: [check-manifest, test, lint] runs-on: ubuntu-latest @@ -90,6 +92,7 @@ jobs: python-version: 3.9 - name: Install Dependencies run: | + git tag python -m pip install --upgrade pip pip install build wheel - name: Build Package diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b3984ad..6b62bfa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -64,13 +64,15 @@ Ready to contribute? Here's how to set up `napari-aicsimageio` for local develop ## Deploying A reminder for the maintainers on how to deploy. -Make sure all your changes are committed. -Then run: +Make sure the main branch is checked out and all desired changes +are merged. Then run: ```bash -$ bumpversion patch # possible: major / minor / patch -$ git push -$ git push --tags +$ git tag -a "vX.Y.Z" -m "vX.Y.Z" +$ git push upstream --follow-tags ``` -This will release a new package version on Git + GitHub and publish to PyPI. +(The `-a` flag indicates an [annotated tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging)) + +This will trigger the `publish` step in the main github workflow, which will build the package +and upload it to PyPI. diff --git a/napari_aicsimageio/__init__.py b/napari_aicsimageio/__init__.py index 82b49bd..249b7a5 100644 --- a/napari_aicsimageio/__init__.py +++ b/napari_aicsimageio/__init__.py @@ -1,12 +1,15 @@ # -*- coding: utf-8 -*- - """Top-level package for napari-aicsimageio.""" +from importlib.metadata import version, PackageNotFoundError + +try: + __version__ = version("napari-aicsimageio") +except PackageNotFoundError: + __version__ = "uninstalled" + __author__ = "Eva Maxfield Brown" __email__ = "evamaxfieldbrown@gmail.com" -# Do not edit this string manually, always use bumpversion -# Details in CONTRIBUTING.md -__version__ = "0.7.0" def get_module_version() -> str: diff --git a/pyproject.toml b/pyproject.toml index 0584935..60c9d57 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,14 +1,13 @@ # https://peps.python.org/pep-0517/ [build-system] -requires = ["setuptools>=45", "wheel"] +requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"] build-backend = "setuptools.build_meta" +[tool.setuptools_scm] + # https://peps.python.org/pep-0621/ [project] name = "napari-aicsimageio" -# Do not edit this string manually, always use bumpversion -# Details in CONTRIBUTING.rst -version = "0.7.0" description = "AICSImageIO bindings for napari" keywords = [ "aicsimageio", @@ -44,7 +43,7 @@ classifiers = [ "Topic :: Scientific/Engineering :: Visualization", "Topic :: Scientific/Engineering", ] -dynamic = [] +dynamic = ["version"] dependencies = [ "aicsimageio[all]>=4.6.3", "fsspec[http]", # no version pin, we pull from aicsimageio @@ -76,7 +75,6 @@ test = [ ] dev = [ "black>=19.10b0", - "bump2version>=1.0.1", "coverage>=5.1", "docutils>=0.10,<0.16", "flake8-debugger>=3.2.1", @@ -119,7 +117,6 @@ use_parentheses = true # https://github.com/mgedmin/check-manifest#configuration [tool.check-manifest] ignore = [ - ".bumpversion.cfg", ".editorconfig", ".napari/**/*", ".pre-commit-config.yaml", From 4a4d97fdb2aedb1c9d6d7b9c88790aab244a21b9 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sun, 24 Jul 2022 14:32:41 -0400 Subject: [PATCH 10/13] clarify comment --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6b62bfa..309e628 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -74,5 +74,5 @@ $ git push upstream --follow-tags (The `-a` flag indicates an [annotated tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging)) -This will trigger the `publish` step in the main github workflow, which will build the package -and upload it to PyPI. +The presence of a tag starting with "v" will trigger the `publish` step in the +main github workflow, which will build the package and upload it to PyPI. From 6f6f0820e5b5d973c8e5c0afc53957debc5f40eb Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sun, 24 Jul 2022 14:34:07 -0400 Subject: [PATCH 11/13] delete bumpversion config --- .bumpversion.cfg | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 .bumpversion.cfg diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index 01df58c..0000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,16 +0,0 @@ -# https://github.com/c4urself/bump2version/issues/42 -# :( -[bumpversion] -current_version = 0.7.0 -parse = (?P\d+)\.(?P\d+)\.(?P\d+) -serialize = {major}.{minor}.{patch} -commit = True -tag = True - -[bumpversion:file:setup.py] -search = version="{current_version}" -replace = version="{new_version}" - -[bumpversion:file:napari_aicsimageio/__init__.py] -search = {current_version} -replace = {new_version} From 25e491d2b283843d4e8cd668a7c31d92e9122d53 Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sun, 24 Jul 2022 14:35:04 -0400 Subject: [PATCH 12/13] lint --- napari_aicsimageio/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napari_aicsimageio/__init__.py b/napari_aicsimageio/__init__.py index 249b7a5..8507bbe 100644 --- a/napari_aicsimageio/__init__.py +++ b/napari_aicsimageio/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Top-level package for napari-aicsimageio.""" -from importlib.metadata import version, PackageNotFoundError +from importlib.metadata import PackageNotFoundError, version try: __version__ = version("napari-aicsimageio") From a16e500e98a6547ce88fd81b4067387c1c61ad4f Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sun, 24 Jul 2022 14:36:30 -0400 Subject: [PATCH 13/13] another comment --- CONTRIBUTING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 309e628..c670e4c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -75,4 +75,6 @@ $ git push upstream --follow-tags (The `-a` flag indicates an [annotated tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging)) The presence of a tag starting with "v" will trigger the `publish` step in the -main github workflow, which will build the package and upload it to PyPI. +main github workflow, which will build the package and upload it to PyPI. The +version will be injected into the package metadata by +[`setuptools-scm`](https://github.com/pypa/setuptools_scm) \ No newline at end of file