@@ -224,13 +224,14 @@ def _add_directory(
224224 path .insert (where , subdir )
225225
226226
227- def _find_include_file (self : pil_build_ext , include : str ) -> int :
227+ def _find_include_file (self : pil_build_ext , include : str ) -> str | None :
228228 for directory in self .compiler .include_dirs :
229229 _dbg ("Checking for include file %s in %s" , (include , directory ))
230- if os .path .isfile (os .path .join (directory , include )):
230+ path = os .path .join (directory , include )
231+ if os .path .isfile (path ):
231232 _dbg ("Found %s" , include )
232- return 1
233- return 0
233+ return path
234+ return None
234235
235236
236237def _find_library_file (self : pil_build_ext , library : str ) -> str | None :
@@ -852,9 +853,13 @@ def build_extensions(self) -> None:
852853
853854 if feature .want ("avif" ):
854855 _dbg ("Looking for avif" )
855- if _find_include_file (self , "avif/avif.h" ):
856- if _find_library_file (self , "avif" ):
857- feature .set ("avif" , "avif" )
856+ if avif_h := _find_include_file (self , "avif/avif.h" ):
857+ with open (avif_h , "rb" ) as fp :
858+ major_version = int (
859+ fp .read ().split (b"#define AVIF_VERSION_MAJOR " )[1 ].split ()[0 ]
860+ )
861+ if major_version >= 1 and _find_library_file (self , "avif" ):
862+ feature .set ("avif" , "avif" )
858863
859864 for f in feature :
860865 if not feature .get (f ) and feature .require (f ):
0 commit comments