From d348d1581e80573eb997a0fd59c81dbdb88e62f2 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Sat, 17 Jan 2015 23:48:06 -0800 Subject: Use homebrew-installed bison, if available This will prevent a "You need bison version 2.5 or more recent" error from jq's `configure` on OS X, if you have Homebrew and bison installed via Homebrew. Refs: #4 --- setup.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index b6b8342..3402dcc 100644 --- a/setup.py +++ b/setup.py @@ -35,10 +35,27 @@ class jq_build_ext(build_ext): tarfile.open(tarball_path, "r:gz").extractall(path_in_dir(".")) def command(args): + print("Executing: %s" % ' '.join(args)) subprocess.check_call(args, cwd=jq_lib_dir) + + configure_args = ["CFLAGS=-fPIC"] + if os.path.exists('/usr/local/bin/brew') and os.path.exists('/usr/local/Cellar'): + print("Found Homebrew installation") + # Mac OS X with Homebrew + # Mac OS X usually ships with an old bison (yacc) + # E.g.: OS X 10.9 has bison 2.3, but jq requires bison >= 2.5 + # Try to use Homebrew version of bison (3.0.3 as of this writing) + try: + yacc = subprocess.check_output("/usr/local/bin/brew ls bison | grep bin/yacc", shell=True).rstrip() + print("Found Homebrew yacc at %s" % yacc) + if yacc: + configure_args.append('YACC=' + yacc) + except subprocess.CalledProcessError: + print("No Homebrew yacc found") + command(["autoreconf", "-i"]) - command(["./configure", "CFLAGS=-fPIC"]) + command(["./configure"] + configure_args) command(["make"]) build_ext.run(self) -- cgit v1.2.3