@@ -224,13 +224,14 @@ def _add_directory(
224
224
path .insert (where , subdir )
225
225
226
226
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 :
228
228
for directory in self .compiler .include_dirs :
229
229
_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 ):
231
232
_dbg ("Found %s" , include )
232
- return 1
233
- return 0
233
+ return path
234
+ return None
234
235
235
236
236
237
def _find_library_file (self : pil_build_ext , library : str ) -> str | None :
@@ -852,9 +853,13 @@ def build_extensions(self) -> None:
852
853
853
854
if feature .want ("avif" ):
854
855
_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" )
858
863
859
864
for f in feature :
860
865
if not feature .get (f ) and feature .require (f ):
0 commit comments