policy: add "cext" package which will host CPython extension modules
authorYuya Nishihara <yuya@tcha.org>
Fri, 12 Aug 2016 11:06:14 +0900
changeset 32211 c48583859e04
parent 32210 56148133ef36
child 32212 65cd7e705ff6
policy: add "cext" package which will host CPython extension modules I'm going to restructure cext/pure modules and get rid of our hgimporter hack. C extension modules will be moved to cext/ directory so old and new compiled modules can coexist in development tree. This is necessary to run 'hg bisect' without recompiling. New extension modules will be loaded by an importer function: base85 = policy.importmod('base85') # select pure.base85 or cext.base85 This will also allow us to split cffi from pure modules, which is currently difficult because pure modules can't be imported by name.
mercurial/cext/__init__.py
setup.py
--- a/setup.py	Tue May 02 18:35:09 2017 +0900
+++ b/setup.py	Fri Aug 12 11:06:14 2016 +0900
@@ -577,7 +577,10 @@
             'build_hgexe': buildhgexe,
             }
 
-packages = ['mercurial', 'mercurial.hgweb', 'mercurial.httpclient',
+packages = ['mercurial',
+            'mercurial.cext',
+            'mercurial.hgweb',
+            'mercurial.httpclient',
             'mercurial.pure',
             'hgext', 'hgext.convert', 'hgext.fsmonitor',
             'hgext.fsmonitor.pywatchman', 'hgext.highlight',
@@ -586,6 +589,7 @@
 common_depends = ['mercurial/bitmanipulation.h',
                   'mercurial/compat.h',
                   'mercurial/util.h']
+common_include_dirs = ['mercurial']
 
 osutil_cflags = []
 osutil_ldflags = []
@@ -615,21 +619,27 @@
 
 extmodules = [
     Extension('mercurial.base85', ['mercurial/base85.c'],
+              include_dirs=common_include_dirs,
               depends=common_depends),
     Extension('mercurial.bdiff', ['mercurial/bdiff.c',
                                   'mercurial/bdiff_module.c'],
+              include_dirs=common_include_dirs,
               depends=common_depends + ['mercurial/bdiff.h']),
     Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c'],
+              include_dirs=common_include_dirs,
               depends=common_depends),
     Extension('mercurial.mpatch', ['mercurial/mpatch.c',
                                    'mercurial/mpatch_module.c'],
+              include_dirs=common_include_dirs,
               depends=common_depends),
     Extension('mercurial.parsers', ['mercurial/dirs.c',
                                     'mercurial/manifest.c',
                                     'mercurial/parsers.c',
                                     'mercurial/pathencode.c'],
+              include_dirs=common_include_dirs,
               depends=common_depends),
     Extension('mercurial.osutil', ['mercurial/osutil.c'],
+              include_dirs=common_include_dirs,
               extra_compile_args=osutil_cflags,
               extra_link_args=osutil_ldflags,
               depends=common_depends),