Skip to content

Commit 00e759f

Browse files
committed
[GR-40155] Improve Pillow installation support on Mac.
PullRequest: graalpython/2370
2 parents c7ae820 + 574747d commit 00e759f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

graalpython/lib-graalpython/modules/ginstall.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,17 @@ def cppy(**kwargs):
363363
def cassowary(**kwargs):
364364
install_from_pypi("cassowary==0.5.2", **kwargs)
365365

366-
@pip_package()
366+
@pip_package(name="PIL")
367367
def Pillow(**kwargs):
368368
setuptools(**kwargs)
369369
build_env = {"MAX_CONCURRENCY": "0"}
370-
install_from_pypi("Pillow==6.2.0", build_cmd=["build_ext", "--disable-jpeg"], env=build_env, **kwargs)
370+
build_cmd = ["build_ext", "--disable-jpeg"]
371+
zlib_root = os.environ.get("ZLIB_ROOT", None)
372+
if zlib_root:
373+
build_cmd += ["-I", os.path.join(zlib_root, "include"), "-L", os.path.join(zlib_root, "lib")]
374+
else:
375+
info("If Pillow installation fails due to missing zlib, try to set environment variable ZLIB_ROOT.")
376+
install_from_pypi("Pillow==6.2.0", build_cmd=build_cmd, env=build_env, **kwargs)
371377

372378
@pip_package()
373379
def matplotlib(**kwargs):
@@ -448,6 +454,10 @@ def _install_from_url(url, package, extra_opts=[], add_cflags="", ignore_errors=
448454
cflags = os_env.get("CFLAGS", "") + ((" " + add_cflags) if add_cflags else "")
449455
setup_env['CFLAGS'] = cflags if cflags else ""
450456

457+
user_build_cmd = os_env.get("GINSTALL_BUILD_CMD", "")
458+
if user_build_cmd:
459+
build_cmd = user_build_cmd.split(" ")
460+
451461
bare_name = _download_with_curl_and_extract(tempdir, url, quiet=quiet)
452462

453463
file_realpath = os.path.dirname(os.path.realpath(__file__))

0 commit comments

Comments
 (0)