Skip to content

Commit

Permalink
detect problematic combination of pydantic and napari
Browse files Browse the repository at this point in the history
  • Loading branch information
Czaki committed Jul 19, 2024
1 parent 8fb6adb commit 3041bf8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions package/PartSeg/launcher_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
from contextlib import suppress
from functools import partial

from PartSeg._launcher.check_survey import CheckSurveyThread

multiprocessing.freeze_support()


Expand Down Expand Up @@ -81,7 +79,17 @@ def create_parser():
return parser


def main(): # pragma: no cover
def main(): # pragma: no cover # noqa: PLR0915
from importlib.metadata import version

from packaging.version import parse as parse_version

napari_version = parse_version(version("napari"))
pydantic_version = parse_version(version("pydantic"))
if napari_version < parse_version("0.4.19") and pydantic_version >= parse_version("2"):
print("napari version is too low, please update to version 0.4.19 or higher or downgrade pydantic to version 1")
sys.exit(1)

if len(sys.argv) > 1 and sys.argv[1] == "_test":
_test_imports()
return
Expand All @@ -100,6 +108,7 @@ def main(): # pragma: no cover
from qtpy.QtWidgets import QApplication

from PartSeg import state_store
from PartSeg._launcher.check_survey import CheckSurveyThread
from PartSeg._launcher.check_version import CheckVersionThread
from PartSeg.common_backend import napari_get_settings
from PartSegData import icons_dir
Expand Down

0 comments on commit 3041bf8

Please sign in to comment.