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

login
register
mail settings
Submitter Siddharth Agarwal
Date Sept. 2, 2014, 9:18 p.m.
Message ID <66b1f6588685c43df63c.1409692689@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/5685/
State Changes Requested
Headers show

Comments

Siddharth Agarwal - Sept. 2, 2014, 9:18 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@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.

Patch

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':