Skip to content

Upgrade python support to 3.10-3.12, fix deprecation errors#120

Merged
C-Achard merged 14 commits into
mainfrom
cy/py-312-support
May 19, 2026
Merged

Upgrade python support to 3.10-3.12, fix deprecation errors#120
C-Achard merged 14 commits into
mainfrom
cy/py-312-support

Conversation

@C-Achard
Copy link
Copy Markdown
Collaborator

@C-Achard C-Achard commented May 19, 2026

Scope


Automated summary

This pull request updates the project's Python and dependency management, improves compatibility with newer Python versions, and simplifies the testing and configuration setup. The main themes are modernization of Python version support, dependency and configuration cleanup, and improvements to test reliability and packaging.

Python Version and Dependency Modernization:

  • Dropped support for Python 3.8 and 3.9, and added support for Python 3.11 and 3.12 in pyproject.toml and tox.ini, updating the test matrix and classifiers accordingly. [1] [2]
  • Removed the setup.cfg file in favor of a modern pyproject.toml-based configuration, consolidating all package metadata and dependencies. [1] [2] [3]
  • Updated dependencies: removed tqdm from the main requirements and development dependencies, and added optional extras for crf and pyqt6. [1] [2] [3] [4]

Testing and CI Improvements:

  • Updated tox.ini to use only supported Python versions and platforms, added pyqt6 and crf extras for testing, and removed direct dependency installations in favor of extras. [1] [2]
  • Removed PyQt5 and PySide2 from optional dependencies, and updated test skipping logic in test_weight_download.py to prevent CI freezes on GitHub Actions. [1] [2]
  • Removed custom pytest configuration files and fixtures for Qt, simplifying test environment setup. [1] [2]

Configuration and Linting Cleanup:

  • Removed .isort.cfg and integrated relevant settings into pyproject.toml, also cleaning up old black and isort settings. [1] [2]
  • Updated ruff linter configuration, including rule selection and exclusion of unnecessary settings. [1] [2]

Packaging Improvements:

  • Added napari.yaml to package data and defined the napari manifest entry point in pyproject.toml for correct plugin packaging. [1] [2]
  • Ensured all necessary resource files are included in the package by updating the package-data section.

Minor Code and Usability Tweaks:

  • Fixed the relabel function in correct_labels.py for correct napari viewer initialization.
  • Numpy fixes in worker_inference.py. [1] [2] [3]

These changes collectively make the plugin ready for the current 3.10-3.12 window.

C-Achard added 2 commits May 19, 2026 14:25
Remove legacy packaging and test config files (setup.cfg, requirements.txt, .isort.cfg, napari_cellseg3d/_tests/pytest.ini, and its conftest). Migrate and update metadata in pyproject.toml: bump supported Python classifiers to 3.10–3.12, add napari manifest entry-point, include napari.yaml in package data, simplify dynamic fields, adjust optional dependencies (add PyQt6, pyside6, move pydensecrf2 to crf extra) and streamline dev dependencies (remove black/isort as direct dev deps). Update tooling rules (ruff token change) and remove redundant tool configs. Update tox.ini to target py310/311/312 across linux/windows/macos, expose platform mappings for GH Actions, and switch to using extras for test/crf/pyqt6 while keeping usedevelop and running pytest as the test command.
Skip a test that causes GitHub Actions to freeze by importing pytest and marking it skipped (needs to be fixed or removed). In worker_inference, replace np.reshape(...) with the ndarray.reshape(...) call and remove an obsolete commented reshape for clarity. In dev_scripts/correct_labels, initialize a napari.Viewer and add the image via viewer.add_image instead of calling napari.view_image(), ensuring the image layer is properly created.
@C-Achard C-Achard requested a review from Copilot May 19, 2026 12:51
@C-Achard C-Achard self-assigned this May 19, 2026
@C-Achard C-Achard added bug Something isn't working fix Something needs to be or has been fixed python-version labels May 19, 2026
@C-Achard C-Achard linked an issue May 19, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes package/test configuration for the supported Python 3.10-3.12 range and consolidates dependency and packaging metadata into pyproject.toml.

Changes:

  • Updates tox and project metadata for newer Python versions.
  • Moves/removes legacy packaging, dependency, lint, and Qt test configuration files.
  • Adjusts a napari viewer initialization path, NumPy reshape usage, and CI skip behavior for a weight-download test.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tox.ini Updates tox environment mappings and test extras.
setup.cfg Removes legacy setuptools metadata/configuration.
requirements.txt Removes the standalone requirements list.
pyproject.toml Consolidates packaging metadata, entry points, extras, and lint config.
napari_cellseg3d/dev_scripts/correct_labels.py Changes viewer creation when relabeling.
napari_cellseg3d/code_models/worker_inference.py Minor formatting and reshape update.
napari_cellseg3d/_tests/test_weight_download.py Adds conditional CI skip for the download test.
napari_cellseg3d/_tests/pytest.ini Removes old Qt pytest configuration.
napari_cellseg3d/_tests/conftest.py Removes Qt offscreen test fixture.
.isort.cfg Removes legacy isort config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyproject.toml
Comment thread pyproject.toml
Comment thread pyproject.toml
Comment thread tox.ini Outdated
Comment thread napari_cellseg3d/dev_scripts/correct_labels.py Outdated
Comment thread napari_cellseg3d/_tests/test_weight_download.py
Comment thread napari_cellseg3d/_tests/test_weight_download.py Outdated
C-Achard added 7 commits May 19, 2026 15:20
* Enhance GitHub Actions CI and deploy workflow

Modernize and expand the test-and-deploy workflow: bump action versions (checkout/setup-python), enable pip caching, and broaden the matrix to ubuntu, windows, and macos with Python 3.10–3.12. Add fail-fast:false and platform-specific steps (Linux Qt libs, Windows OpenGL with pwsh). Install tox centrally and run tests per-OS with appropriate Qt/PyQt and PyVista env vars; upload coverage with codecov v6. Adjust deploy job to trigger on semver-style tags (refs/tags/v*), update setup actions, split build and publish steps (build then twine upload), and simplify dependency installs.

* Fix missing OSs in tox.ini
Enable setuptools_scm-based versioning and tighten CI/build checks. Updates include:

- Use setuptools_scm: add setuptools-scm to build-system requires and configure version_file in pyproject.toml so package version is generated into napari_cellseg3d/_version.py.
- Make package import version dynamically: __init__.py now prefers the generated _version and falls back to importlib.metadata.version.
- Bump minimum Python to >=3.10 in pyproject.
- CI/workflow changes: fetch full Git history (fetch-depth: 0), restrict Codecov upload to ubuntu-latest + Python 3.12, pin the build job to Python 3.12, and add a twine check step before publishing.
- Minor dev script cleanup: remove unused assignment when adding image to napari viewer.

These changes improve reproducible versioning, ensure the build uses an appropriate Python/tooling set, and add a safety check before publishing.
Use the generic CI environment variable when skipping the weight download test (os.getenv("CI") instead of "GITHUB_ACTIONS") and update the skip reason to mention CI. Also add a small formatting tweak (blank line after import) and adjust file ending.
Expand unit test coverage for napari_cellseg3d.code_plugins.plugin_base. Rename a test for updating default paths and add many new tests covering: results path creation/validation, _build not implemented, navigation buttons, dock widget removal (including LookupError handling), dataset path extraction, folder plugin default path updates, dataset loading (images, labels, unsupervised), dataset load warnings, file/folder dialog integrations (filetype and path updates), and visibility helpers. Also add necessary imports and use plugin_base for monkeypatching ui/utils/logger behaviors.
Add Windows-specific environment variables to tox.ini passenv: set USERNAME to 'runneradmin' and TORCHINDUCTOR_CACHE_DIR to {envtmpdir}/torchinductor. Ensures Windows test runs use a consistent username and place TorchInductor cache in the temporary directory.
Update test_make_navigation_buttons to use real QWidget instances and the qtbot fixture instead of SimpleNamespace. The test now accepts qtbot, creates two QWidgets, registers them with qtbot.addWidget, and adds them as tabs before checking navigation buttons—ensuring proper Qt widget management and avoiding teardown/warning issues.
Insert the missing `setenv` key in tox.ini so the Windows-specific environment variables (USERNAME, TORCHINDUCTOR_CACHE_DIR) are declared under the correct section. This fixes configuration formatting and ensures those variables are applied in tox runs on Windows.
@C-Achard C-Achard requested a review from Copilot May 19, 2026 13:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.

Comment thread .github/workflows/test_and_deploy.yml
Comment thread pyproject.toml Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@C-Achard C-Achard requested a review from Copilot May 19, 2026 14:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated no new comments.

This reverts commit 89921c7.
Update test_relabel to use the make_napari_viewer_proxy fixture: create a viewer instance and pass it to cl.relabel via viewer=viewer. This ensures the relabel test runs with a proxied Napari viewer (e.g. for headless/test environments) and verifies behavior when a viewer is provided.
@C-Achard C-Achard added this to the Python 3.10-3.12 support milestone May 19, 2026
@C-Achard C-Achard marked this pull request as ready for review May 19, 2026 15:13
@C-Achard C-Achard changed the title Upgrade python support to 3.10-3.12 Upgrade python support to 3.10-3.12, fix deprecation errors May 19, 2026
@C-Achard C-Achard requested a review from MMathisLab May 19, 2026 15:13
@C-Achard
Copy link
Copy Markdown
Collaborator Author

Confirmed: inference works on all models + GPU support is fine

@C-Achard C-Achard merged commit 3a52686 into main May 19, 2026
25 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fix Something needs to be or has been fixed python-version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Colab inference demo incompatible with current MONAI and NumPy

3 participants