Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 44 additions & 15 deletions src/napari_plugin_manager/qt_package_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,58 @@
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,
InstallerQueue,
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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not know how to prevent installing additional backend on conda.



def _get_python_exe():
# Note: is_bundled_app() returns False even if using a Briefcase bundle...
Expand All @@ -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)
Expand All @@ -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):
Expand Down
Loading