Patchwork [09,of,12] policy: add "cext" package which will host CPython extension modules

login
register
mail settings
Submitter Yuya Nishihara
Date May 7, 2017, 1:45 a.m.
Message ID <105a90d392d5ea39260d.1494121550@mimosa>
Download mbox | patch
Permalink /patch/20507/
State Accepted
Headers show

Comments

Yuya Nishihara - May 7, 2017, 1:45 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1470967574 -32400
#      Fri Aug 12 11:06:14 2016 +0900
# Node ID 105a90d392d5ea39260dfe90426cc812f98998fd
# Parent  eb86791ad01c90493405b7968ebaec79b88081a7
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.

Patch

diff --git a/mercurial/cext/__init__.py b/mercurial/cext/__init__.py
new file mode 100644
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -577,7 +577,10 @@  cmdclass = {'build': hgbuild,
             '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 @@  packages = ['mercurial', 'mercurial.hgwe
 common_depends = ['mercurial/bitmanipulation.h',
                   'mercurial/compat.h',
                   'mercurial/util.h']
+common_include_dirs = ['mercurial']
 
 osutil_cflags = []
 osutil_ldflags = []
@@ -615,21 +619,27 @@  if sys.platform == 'darwin':
 
 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),