From ae257047ef57040b355d256676ff561c7c537f93 Mon Sep 17 00:00:00 2001 From: Luis Pedro Coelho Date: Fri, 3 May 2024 09:49:47 +1000 Subject: [PATCH] MIN Add deprecation error if FreeImage is used --- ChangeLog | 3 +++ mahotas/io/__init__.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index e3e25972..12a992f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +Unreleased + * io: Add deprecated warning for freeimage + Version 1.4.15 2024-04-17 by luispedro * Update build system (thanks to @Czaki, see #147) diff --git a/mahotas/io/__init__.py b/mahotas/io/__init__.py index 3c0537c3..4a9a96b4 100644 --- a/mahotas/io/__init__.py +++ b/mahotas/io/__init__.py @@ -62,6 +62,11 @@ def error_imsave(*args, **kwargs): from .pil import imread, imsave except ImportError: from .freeimage import imread, imsave + from os import environ + if 'MAHOTAS_NO_FREEIMAGE_DEPRECATION' not in environ: + import warnings + warnings.warn('mahotas.freeimage is deprecated. Please install the `imread` package') + warnings.warn('To suppress this warning, set the environment variable MAHOTAS_NO_FREEIMAGE_DEPRECATION') # Importing freeimage can throw both ImportError and OSError, so check for both except (OSError, ImportError): # pragma: no cover import sys