diff --git a/src/napari_plugin_manager/qt_package_installer.py b/src/napari_plugin_manager/qt_package_installer.py index e3f7b15f..e862747c 100644 --- a/src/napari_plugin_manager/qt_package_installer.py +++ b/src/napari_plugin_manager/qt_package_installer.py @@ -11,12 +11,13 @@ import os import sys from functools import lru_cache +from importlib.metadata import version as package_version from pathlib import Path from tempfile import NamedTemporaryFile from typing import Sequence -from napari._version import version as _napari_version -from napari._version import version_tuple as _napari_version_tuple +import qtpy +from packaging.version import parse as parse_version from napari_plugin_manager.base_qt_package_installer import ( CondaInstallerTool, @@ -24,6 +25,44 @@ PipInstallerTool, ) +CRITICAL_PACKAGES = [ + "app-model", + "lazy_loader", + "magicgui", + "napari", + "numpy", + "psygnal", + "pydantic", + "superqt", + "vispy", +] + +QT_BACKENDS = ["PyQt5", "PySide2", "PySide6", "PyQt6"] +CURRENT_BACKEND = qtpy.API_NAME + +QT_BACKENDS_PIN = [ + ( + f"{pkg}=={package_version(pkg)}" + if pkg == CURRENT_BACKEND + else f"{pkg}==0" + ) + for pkg in QT_BACKENDS +] + +CRITICAL_PACKAGES_PIN = [ + f"{pkg}=={package_version(pkg)}" for pkg in CRITICAL_PACKAGES +] + QT_BACKENDS_PIN + +# dev or rc versions might not be available in public channels +# but only installed locally - if we try to pin those, mamba +# will fail to pin it because there's no record of that version +# in the remote index, only locally; to work around this bug +# we will have to pin to e.g. 0.4.* instead of 0.4.17.* for now +CRITICAL_PACKAGES_PIN_CONDA = [ + f"{pkg}={parse_version(package_version(pkg)).base_version}" + for pkg in CRITICAL_PACKAGES +] # + QT_BACKENDS_PIN + def _get_python_exe(): # Note: is_bundled_app() returns False even if using a Briefcase bundle... @@ -48,7 +87,7 @@ def constraints() -> Sequence[str]: """ Version constraints to limit unwanted changes in installation. """ - return [f"napari=={_napari_version}", "numpy<2"] + return CRITICAL_PACKAGES_PIN @classmethod @lru_cache(maxsize=0) @@ -64,18 +103,8 @@ def _constraints_file(cls) -> str: class NapariCondaInstallerTool(CondaInstallerTool): @staticmethod def constraints() -> Sequence[str]: - # FIXME - # dev or rc versions might not be available in public channels - # but only installed locally - if we try to pin those, mamba - # will fail to pin it because there's no record of that version - # in the remote index, only locally; to work around this bug - # we will have to pin to e.g. 0.4.* instead of 0.4.17.* for now - version_lower = _napari_version.lower() - is_dev = "rc" in version_lower or "dev" in version_lower - pin_level = 2 if is_dev else 3 - version = ".".join([str(x) for x in _napari_version_tuple[:pin_level]]) - - return [f"napari={version}", "numpy<2.0a0"] + + return CRITICAL_PACKAGES_PIN_CONDA class NapariInstallerQueue(InstallerQueue):