Skip to content

Commit a279fff

Browse files
committed
corrected build under MINGW #178
Signed-off-by: Alexander Piskun <[email protected]>
1 parent 460a1b5 commit a279fff

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

setup.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
# pylint: disable=too-many-branches disable=too-many-statements disable=too-many-locals
1717
LIBHEIF_ROOT = None
18+
PLATFORM_MINGW = os.name == "nt" and "GCC" in sys.version
1819

1920

2021
class RequiredDependencyException(Exception):
@@ -165,9 +166,12 @@ def build_extensions(self): # noqa
165166
# ATTENTION: If someone knows how without hacks include MSYS2 directory as last directory in list - help!
166167
self.compiler.include_dirs.append(os.path.dirname(os.path.abspath(__file__)))
167168

168-
self._update_extension(
169-
"_pillow_heif", ["libheif"], extra_compile_args=["/d2FH4-", "/WX"], extra_link_args=["/WX"]
170-
)
169+
if PLATFORM_MINGW:
170+
self._update_extension("_pillow_heif", ["heif"], extra_compile_args=["-Ofast", "-Werror"])
171+
else:
172+
self._update_extension(
173+
"_pillow_heif", ["libheif"], extra_compile_args=["/d2FH4-", "/WX"], extra_link_args=["/WX"]
174+
)
171175
elif sys.platform.lower() == "darwin":
172176
try: # if Homebrew is installed, use its lib and include directories
173177
homebrew_prefix = subprocess.check_output(["brew", "--prefix"]).strip().decode("latin1")
@@ -267,6 +271,7 @@ def _get_macos_sdk_path():
267271
version=get_version(),
268272
cmdclass={"build_ext": PillowHeifBuildExt},
269273
ext_modules=[Extension("_pillow_heif", ["pillow_heif/_pillow_heif.c"])],
274+
zip_safe=not PLATFORM_MINGW,
270275
)
271276
except RequiredDependencyException as err:
272277
msg = f"""

0 commit comments

Comments
 (0)