diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-06-19 00:16:48 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-06-19 00:16:48 +0100 |
| commit | 736d9f8a23e48559cad7076851db1c1c5b891532 (patch) | |
| tree | 01a1ab005caef7e9d48032cf3bd5c6f9a1d43878 /setup.py | |
| parent | c9c0481862a0c96c016660d50d3fa3f733424180 (diff) | |
Grab a copy of jq during build
Diffstat (limited to 'setup.py')
| -rw-r--r-- | setup.py | 43 |
1 files changed, 39 insertions, 4 deletions
@@ -1,19 +1,53 @@ #!/usr/bin/env python import os +import subprocess from setuptools import setup from distutils.extension import Extension +from distutils.command.build_ext import build_ext + + +def path_in_dir(relative_path): + return os.path.join(os.path.dirname(__file__), relative_path) def read(fname): - return open(os.path.join(os.path.dirname(__file__), fname)).read() + return open(path_in_dir(fname)).read() + + +jq_lib_dir = path_in_dir("_jq-lib") + +class jq_build_ext(build_ext): + def run(self): + + def command(args): + subprocess.check_call(args, cwd=path_in_dir(jq_lib_dir)) + + if os.path.exists(jq_lib_dir): + command(["git", "pull"]) + else: + subprocess.check_call([ + "git", "clone", + "https://github.com/nicowilliams/jq.git", + jq_lib_dir + ]) + + # Tested with commit db9e52ee57 + command(["git", "checkout", "libjq"]) + command(["autoreconf", "-i"]) + command(["./configure", "CFLAGS=-fPIC"]) + command(["make", "clean"]) + command(["make"]) + + build_ext.run(self) + jq_extension = Extension( "jq", sources=["jq.c"], - include_dirs=["../jq/"], + include_dirs=[jq_lib_dir], libraries=["jq"], - library_dirs=["../jq/"], + library_dirs=[jq_lib_dir], ) setup( @@ -23,6 +57,7 @@ setup( long_description=read("README"), author='Michael Williamson', url='http://github.com/mwilliamson/jq.py', - ext_modules = [jq_extension] + ext_modules = [jq_extension], + cmdclass={"build_ext": jq_build_ext} ) |
