From 067177dc95ac9d0791b29f2770ac5b55d82dc5e2 Mon Sep 17 00:00:00 2001 From: Jason Paryani Date: Fri, 12 Dec 2014 15:15:18 -0800 Subject: [PATCH] Add install flags --force-bundled-libcapnp and --force-system-libcapnp --- setup.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 44c981d..bae80ec 100644 --- a/setup.py +++ b/setup.py @@ -17,6 +17,7 @@ if setuptools_version < '0.8': from distutils.core import setup import os +import sys from buildutils import test_build, fetch_libcapnp, build_libcapnp, info from distutils.errors import CompileError from distutils.extension import Extension @@ -70,6 +71,13 @@ class clean(_clean): except OSError: pass +# hack to parse commandline arguments +force_bundled_libcapnp = "--force-bundled-libcapnp" in sys.argv +if force_bundled_libcapnp: + sys.argv.remove("--force-bundled-libcapnp") +force_system_libcapnp = "--force-system-libcapnp" in sys.argv +if force_system_libcapnp: + sys.argv.remove("--force-system-libcapnp") class build_libcapnp_ext(build_ext_c): @@ -77,10 +85,17 @@ class build_libcapnp_ext(build_ext_c): build_ext_c.build_extension(self, ext) def run(self): + build_failed = False try: test_build() except CompileError: - info("*WARNING* no libcapnp detected. Will download and build it from source now. If you have C++ Cap'n Proto installed, it may be out of date or is not being detected. Downloading and building libcapnp may take a while.") + build_failed = True + + if build_failed and force_system_libcapnp: + raise RuntimeError("libcapnp C++ library not detected and --force-system-libcapnp was used") + if build_failed or force_bundled_libcapnp: + if build_failed: + info("*WARNING* no libcapnp detected. Will download and build it from source now. If you have C++ Cap'n Proto installed, it may be out of date or is not being detected. Downloading and building libcapnp may take a while.") bundle_dir = os.path.join(_this_dir, "bundled") if not os.path.exists(bundle_dir): os.mkdir(bundle_dir)