changeset 32506:2dcb3d52ef41

cffi: put compiled modules into mercurial.cffi package Don't pollute the top-level namespace.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 02 May 2017 21:08:38 +0900
parents 05a16c19967e
children 95085d747db8
files mercurial/cffi/bdiffbuild.py mercurial/cffi/mpatchbuild.py mercurial/cffi/osutilbuild.py mercurial/pure/bdiff.py mercurial/pure/mpatch.py mercurial/pure/osutil.py setup.py
diffstat 7 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cffi/bdiffbuild.py	Tue May 02 21:04:40 2017 +0900
+++ b/mercurial/cffi/bdiffbuild.py	Tue May 02 21:08:38 2017 +0900
@@ -4,7 +4,7 @@
 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("""
--- a/mercurial/cffi/mpatchbuild.py	Tue May 02 21:04:40 2017 +0900
+++ b/mercurial/cffi/mpatchbuild.py	Tue May 02 21:08:38 2017 +0900
@@ -6,7 +6,7 @@
 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("""
 
--- a/mercurial/cffi/osutilbuild.py	Tue May 02 21:04:40 2017 +0900
+++ b/mercurial/cffi/osutilbuild.py	Tue May 02 21:08:38 2017 +0900
@@ -3,7 +3,7 @@
 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>
--- a/mercurial/pure/bdiff.py	Tue May 02 21:04:40 2017 +0900
+++ b/mercurial/pure/bdiff.py	Tue May 02 21:08:38 2017 +0900
@@ -96,7 +96,7 @@
 
 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
--- a/mercurial/pure/mpatch.py	Tue May 02 21:04:40 2017 +0900
+++ b/mercurial/pure/mpatch.py	Tue May 02 21:08:38 2017 +0900
@@ -130,7 +130,7 @@
 
 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
--- a/mercurial/pure/osutil.py	Tue May 02 21:04:40 2017 +0900
+++ b/mercurial/pure/osutil.py	Tue May 02 21:08:38 2017 +0900
@@ -71,7 +71,7 @@
 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
--- a/setup.py	Tue May 02 21:04:40 2017 +0900
+++ b/setup.py	Tue May 02 21:08:38 2017 +0900
@@ -582,6 +582,7 @@
 
 packages = ['mercurial',
             'mercurial.cext',
+            'mercurial.cffi',
             'mercurial.hgweb',
             'mercurial.httpclient',
             'mercurial.pure',