@@ -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 :
@@ -871,10 +872,15 @@ def build_extensions(self) -> None:
871872
872873 if feature .want ("avif" ):
873874 _dbg ("Looking for avif" )
874- if _find_include_file (self , "avif/avif.h" ):
875- lib_avif = _find_library_file (self , "avif" )
876- if lib_avif is not None :
877- feature .set ("avif" , lib_avif )
875+ if avif_h := _find_include_file (self , "avif/avif.h" ):
876+ with open (avif_h , "rb" ) as fp :
877+ major_version = int (
878+ fp .read ().split (b"#define AVIF_VERSION_MAJOR " )[1 ].split ()[0 ]
879+ )
880+ if major_version >= 1 :
881+ lib_avif = _find_library_file (self , "avif" )
882+ if lib_avif is not None :
883+ feature .set ("avif" , lib_avif )
878884
879885 for f in feature :
880886 if not feature .get (f ) and feature .require (f ):
0 commit comments