summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Abramowitz <marc@marc-abramowitz.com>2015-01-17 23:48:06 -0800
committerMarc Abramowitz <marc@marc-abramowitz.com>2015-01-18 00:48:11 -0800
commitd348d1581e80573eb997a0fd59c81dbdb88e62f2 (patch)
tree9522d6cae464b97887cff027aa80368d3c91b0cd
parent34899377fab99a79a67b0f01b5746ffe3192ca08 (diff)
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
-rw-r--r--setup.py19
1 files changed, 18 insertions, 1 deletions
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)