[PATCH 2 of 3 RFC] setup: build re2 extension if required headers are present

Siddharth Agarwal sid0 at fb.com
Tue Sep 2 16:18:09 CDT 2014


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1409685935 25200
#      Tue Sep 02 12:25:35 2014 -0700
# Node ID 66b1f6588685c43df63c82be83a3dc759977328a
# Parent  f3b022e755dd7cf54e1ded55f0217bb1415348e2
setup: build re2 extension if required headers are present

If the re2 header is present, this will cause the re2 extension to be built as
mercurial/_re2.so. Otherwise we'll print a warning

I believe this needs to be a separate extension (not in parsers.c or
similar) -- I couldn't find a way in setup.py to say certain files in a module
are optional and others aren't.

diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -453,6 +453,11 @@
               depends=common_depends),
     ]
 
+re2module = Extension('mercurial._re2', ['mercurial/pyre2/_re2.cc'],
+                      libraries=['re2'])
+re2module.optional = True
+extmodules.append(re2module)
+
 osutil_ldflags = []
 
 if sys.platform == 'darwin':


More information about the Mercurial-devel mailing list