Simplified code

This commit is contained in:
Andrew Murray 2024-08-13 19:05:32 +10:00
parent 5546994828
commit f3aec6dd38

View File

@ -794,25 +794,17 @@ class pil_build_ext(build_ext):
if feature.want("webp"): if feature.want("webp"):
_dbg("Looking for webp") _dbg("Looking for webp")
if all( if all(
_find_include_file(self, src) _find_include_file(self, "webp/" + include)
for src in [ for include in ("encode.h", "decode.h", "mux.h", "demux.h")
"webp/encode.h",
"webp/decode.h",
"webp/mux.h",
"webp/demux.h",
]
): ):
# In Google's precompiled zip it is call "libwebp": # In Google's precompiled zip it is called "libwebp"
for prefix in ("", "lib"):
if all( if all(
_find_library_file(self, lib) _find_library_file(self, prefix + library)
for lib in ["webp", "webpmux", "webpdemux"] for library in ("webp", "webpmux", "webpdemux")
): ):
feature.webp = "webp" feature.webp = prefix + "webp"
elif all( break
_find_library_file(self, lib)
for lib in ["libwebp", "libwebpmux", "libwebpdemux"]
):
feature.webp = "libwebp"
if feature.want("xcb"): if feature.want("xcb"):
_dbg("Looking for xcb") _dbg("Looking for xcb")
@ -901,12 +893,8 @@ class pil_build_ext(build_ext):
self._remove_extension("PIL._imagingcms") self._remove_extension("PIL._imagingcms")
if feature.webp: if feature.webp:
libs = [ libs = [feature.webp, feature.webp + "mux", feature.webp + "demux"]
feature.webp, self._update_extension("PIL._webp", libs)
feature.webp + "mux",
feature.webp + "demux",
]
self._update_extension("PIL._webp", libs, [])
else: else:
self._remove_extension("PIL._webp") self._remove_extension("PIL._webp")