From b6b0a6ba8c3d1aa9363e3bc4e1c9d07c7b0091c0 Mon Sep 17 00:00:00 2001 From: Gregory Lee Date: Mon, 16 Dec 2024 10:37:15 -0500 Subject: [PATCH] fix private import to work across scikit-image versions --- .../cucim/skimage/morphology/_skeletonize.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/python/cucim/src/cucim/skimage/morphology/_skeletonize.py b/python/cucim/src/cucim/skimage/morphology/_skeletonize.py index 6193a17d..81daf1dd 100644 --- a/python/cucim/src/cucim/skimage/morphology/_skeletonize.py +++ b/python/cucim/src/cucim/skimage/morphology/_skeletonize.py @@ -252,13 +252,16 @@ def medial_axis(image, mask=None, return_distance=False, *, rng=None): """ try: - from skimage.morphology._skeletonize_cy import _skeletonize_loop - except ImportError as e: - warnings.warn( - "Could not find required private skimage Cython function:\n" - "\tskimage.morphology._skeletonize_cy._skeletonize_loop\n" - ) - raise e + from skimage.morphology._skeletonize import _skeletonize_loop + except ImportError: + try: + from skimage.morphology._skeletonize_cy import _skeletonize_loop + except ImportError as e: + warnings.warn( + "Could not find required private skimage Cython function:\n" + "\tskimage.morphology._skeletonize_cy._skeletonize_loop\n" + ) + raise e if mask is None: # masked_image is modified in-place later so make a copy of the input