Add --libcapnp-url to allow installing arbitrary libcapnp versions
This commit is contained in:
@@ -21,6 +21,11 @@ Note: for OSX, if using clang from Xcode 5, you may need to set `CFLAGS` like so
|
||||
|
||||
CFLAGS='-stdlib=libc++' pip install pycapnp
|
||||
|
||||
If you wish to install using the latest upstream C++ Cap'n Proto:
|
||||
|
||||
pip install --install-option "--libcapnp-url" --install-option "https://github.com/sandstorm-io/capnproto/archive/master.tar.gz" --install-option "--force-bundled-libcapnp" .
|
||||
|
||||
|
||||
## Python Versions
|
||||
|
||||
Python 2.6/2.7 are supported as well as Python 3.2+. PyPy 2.1+ is also supported.
|
||||
|
||||
@@ -73,19 +73,32 @@ def fetch_archive(savedir, url, fname, force=False):
|
||||
# libcapnp
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
def fetch_libcapnp(savedir):
|
||||
def fetch_libcapnp(savedir, url=None):
|
||||
"""download and extract libcapnp"""
|
||||
is_preconfigured = False
|
||||
if url is None:
|
||||
url = libcapnp_url
|
||||
is_preconfigured = True
|
||||
dest = pjoin(savedir, 'capnproto-c++')
|
||||
if os.path.exists(dest):
|
||||
info("already have %s" % dest)
|
||||
return
|
||||
fname = fetch_archive(savedir, libcapnp_url, libcapnp)
|
||||
fname = fetch_archive(savedir, url, libcapnp)
|
||||
tf = tarfile.open(fname)
|
||||
with_version = pjoin(savedir, tf.firstmember.path)
|
||||
tf.extractall(savedir)
|
||||
tf.close()
|
||||
# remove version suffix:
|
||||
if is_preconfigured:
|
||||
shutil.move(with_version, dest)
|
||||
else:
|
||||
cpp_dir = os.path.join(with_version, 'c++')
|
||||
conf = Popen(['autoreconf', '-i'], cwd=cpp_dir)
|
||||
returncode = conf.wait()
|
||||
if returncode != 0:
|
||||
raise RuntimeError('Autoreconf failed. Make sure autotools are installed on your system.')
|
||||
shutil.move(cpp_dir, dest)
|
||||
|
||||
|
||||
def stage_platform_hpp(capnproot):
|
||||
"""stage platform.hpp into libcapnp sources
|
||||
@@ -162,4 +175,3 @@ def copy_and_patch_libcapnp(capnp, libcapnp):
|
||||
out,err = p.communicate()
|
||||
if p.returncode:
|
||||
fatal("Could not patch bundled libcapnp install_name: %s"%err, p.returncode)
|
||||
|
||||
|
||||
10
setup.py
10
setup.py
@@ -79,6 +79,14 @@ force_cython = "--force-cython" in sys.argv
|
||||
if force_cython:
|
||||
sys.argv.remove("--force-cython")
|
||||
use_cython = True
|
||||
libcapnp_url = None
|
||||
try:
|
||||
libcapnp_url_index = sys.argv.index("--libcapnp-url")
|
||||
libcapnp_url = sys.argv[libcapnp_url_index + 1]
|
||||
sys.argv.remove("--libcapnp-url")
|
||||
sys.argv.remove(libcapnp_url)
|
||||
except:
|
||||
pass
|
||||
|
||||
if use_cython:
|
||||
from Cython.Distutils import build_ext as build_ext_c
|
||||
@@ -107,7 +115,7 @@ class build_libcapnp_ext(build_ext_c):
|
||||
build_dir = os.path.join(_this_dir, "build")
|
||||
if not os.path.exists(build_dir):
|
||||
os.mkdir(build_dir)
|
||||
fetch_libcapnp(bundle_dir)
|
||||
fetch_libcapnp(bundle_dir, libcapnp_url)
|
||||
|
||||
build_libcapnp(bundle_dir, build_dir)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user