Skip to content

Commit 2908c21

Browse files
committed
Honor env vars CFLAGS and CPPFLAGS in 'ginstall.py'.
1 parent b589861 commit 2908c21

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

graalpython/lib-graalpython/modules/ginstall.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def pandas(*args):
378378
379379
"""
380380
cflags = "-allowcpp" if sys.implementation.name == "graalpython" else ""
381-
install_from_url("https://files.pythonhosted.org/packages/ee/aa/90c06f249cf4408fa75135ad0df7d64c09cf74c9870733862491ed5f3a50/pandas-0.20.3.tar.gz", patch=patch, extra_opts=args, cflags=cflags)
381+
install_from_url("https://files.pythonhosted.org/packages/ee/aa/90c06f249cf4408fa75135ad0df7d64c09cf74c9870733862491ed5f3a50/pandas-0.20.3.tar.gz", patch=patch, extra_opts=args, add_cflags=cflags)
382382

383383
return locals()
384384

@@ -391,7 +391,7 @@ def xit(msg, status=-1):
391391
exit(-1)
392392

393393

394-
def install_from_url(url, patch=None, extra_opts=[], cflags=""):
394+
def install_from_url(url, patch=None, extra_opts=[], add_cflags=""):
395395
name = url[url.rfind("/")+1:]
396396
tempdir = tempfile.mkdtemp()
397397

@@ -403,6 +403,10 @@ def install_from_url(url, patch=None, extra_opts=[], cflags=""):
403403
elif url.startswith("https://") and "HTTPS_PROXY" in env:
404404
curl_opts += ["--proxy", env["HTTPS_PROXY"]]
405405

406+
# honor env var 'CFLAGS' and 'CPPFLAGS'
407+
cppflags = os.environ.get("CPPFLAGS", "")
408+
cflags = "-v " + os.environ.get("CFLAGS", "") + ((" " + add_cflags) if add_cflags else "")
409+
406410
system("curl %s -o %s/%s %s" % (" ".join(curl_opts), tempdir, name, url))
407411
if name.endswith(".tar.gz"):
408412
system("tar xzf %s/%s -C %s" % (tempdir, name, tempdir))
@@ -420,7 +424,7 @@ def install_from_url(url, patch=None, extra_opts=[], cflags=""):
420424
user_arg = "--user"
421425
else:
422426
user_arg = ""
423-
system("cd %s/%s; %s %s setup.py install %s %s" % (tempdir, bare_name, "CFLAGS=%s" % cflags if cflags else "", sys.executable, user_arg, " ".join(extra_opts)))
427+
system("cd %s/%s; %s %s %s setup.py install %s %s" % (tempdir, bare_name, 'CFLAGS="%s"' % cflags if cflags else "", 'CPPFLAGS="%s"' % cppflags if cppflags else "", sys.executable, user_arg, " ".join(extra_opts)))
424428

425429

426430
def install_from_pypi(package, extra_opts=[]):

0 commit comments

Comments
 (0)