Patchwork [02,of,10] cffi: put compiled modules into mercurial.cffi package

login
register
mail settings
Submitter Yuya Nishihara
Date May 28, 2017, 1:05 p.m.
Message ID <1402f57f72fef5df62d6.1495976707@mimosa>
Download mbox | patch
Permalink /patch/20975/
State Accepted
Headers show

Comments

Yuya Nishihara - May 28, 2017, 1:05 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1493726918 -32400
#      Tue May 02 21:08:38 2017 +0900
# Node ID 1402f57f72fef5df62d6d2200db567ea39f6eb04
# Parent  84957771591a5c5240cb1cc27b5c2c8d269d8eb4
cffi: put compiled modules into mercurial.cffi package

Don't pollute the top-level namespace.

Patch

diff --git a/mercurial/cffi/bdiffbuild.py b/mercurial/cffi/bdiffbuild.py
--- a/mercurial/cffi/bdiffbuild.py
+++ b/mercurial/cffi/bdiffbuild.py
@@ -4,7 +4,7 @@  import cffi
 import os
 
 ffi = cffi.FFI()
-ffi.set_source("_bdiff_cffi",
+ffi.set_source("mercurial.cffi._bdiff",
     open(os.path.join(os.path.join(os.path.dirname(__file__), '..'),
         'bdiff.c')).read(), include_dirs=['mercurial'])
 ffi.cdef("""
diff --git a/mercurial/cffi/mpatchbuild.py b/mercurial/cffi/mpatchbuild.py
--- a/mercurial/cffi/mpatchbuild.py
+++ b/mercurial/cffi/mpatchbuild.py
@@ -6,7 +6,7 @@  import os
 ffi = cffi.FFI()
 mpatch_c = os.path.join(os.path.join(os.path.dirname(__file__), '..',
                                      'mpatch.c'))
-ffi.set_source("_mpatch_cffi", open(mpatch_c).read(),
+ffi.set_source("mercurial.cffi._mpatch", open(mpatch_c).read(),
                include_dirs=["mercurial"])
 ffi.cdef("""
 
diff --git a/mercurial/cffi/osutilbuild.py b/mercurial/cffi/osutilbuild.py
--- a/mercurial/cffi/osutilbuild.py
+++ b/mercurial/cffi/osutilbuild.py
@@ -3,7 +3,7 @@  from __future__ import absolute_import
 import cffi
 
 ffi = cffi.FFI()
-ffi.set_source("_osutil_cffi", """
+ffi.set_source("mercurial.cffi._osutil", """
 #include <sys/attr.h>
 #include <sys/vnode.h>
 #include <unistd.h>
diff --git a/mercurial/pure/bdiff.py b/mercurial/pure/bdiff.py
--- a/mercurial/pure/bdiff.py
+++ b/mercurial/pure/bdiff.py
@@ -96,7 +96,7 @@  def fixws(text, allws):
 
 if modulepolicy not in policynocffi:
     try:
-        from _bdiff_cffi import ffi, lib
+        from ..cffi._bdiff import ffi, lib
     except ImportError:
         if modulepolicy == 'cffi': # strict cffi import
             raise
diff --git a/mercurial/pure/mpatch.py b/mercurial/pure/mpatch.py
--- a/mercurial/pure/mpatch.py
+++ b/mercurial/pure/mpatch.py
@@ -130,7 +130,7 @@  def patchedsize(orig, delta):
 
 if modulepolicy not in policynocffi:
     try:
-        from _mpatch_cffi import ffi, lib
+        from ..cffi._mpatch import ffi, lib
     except ImportError:
         if modulepolicy == 'cffi': # strict cffi import
             raise
diff --git a/mercurial/pure/osutil.py b/mercurial/pure/osutil.py
--- a/mercurial/pure/osutil.py
+++ b/mercurial/pure/osutil.py
@@ -71,7 +71,7 @@  def listdirpure(path, stat=False, skip=N
 ffi = None
 if modulepolicy not in policynocffi and pycompat.sysplatform == 'darwin':
     try:
-        from _osutil_cffi import ffi, lib
+        from ..cffi._osutil import ffi, lib
     except ImportError:
         if modulepolicy == 'cffi': # strict cffi import
             raise
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -582,6 +582,7 @@  cmdclass = {'build': hgbuild,
 
 packages = ['mercurial',
             'mercurial.cext',
+            'mercurial.cffi',
             'mercurial.hgweb',
             'mercurial.httpclient',
             'mercurial.pure',