[pypy-commit] cffi cffi-1.0: the big Moving Files Around step

arigo noreply at buildbot.pypy.org
Tue May 12 11:18:28 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r1987:e5e9670e96d2
Date: 2015-05-12 11:07 +0200
http://bitbucket.org/cffi/cffi/changeset/e5e9670e96d2/

Log:	the big Moving Files Around step

diff --git a/_cffi1/__init__.py b/_cffi1/__init__.py
deleted file mode 100644
--- a/_cffi1/__init__.py
+++ /dev/null
@@ -1,1 +0,0 @@
-from .recompiler import make_c_source, recompile
diff --git a/_cffi1/setup.py b/_cffi1/setup.py
deleted file mode 100644
--- a/_cffi1/setup.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from distutils.core import setup
-from distutils.extension import Extension
-setup(name='realize_c_type',
-      ext_modules=[Extension(name='realize_c_type',
-                             sources=['realize_c_type.c',
-                                      'parse_c_type.c'])])
diff --git a/_cffi1/support.py b/_cffi1/support.py
deleted file mode 100644
--- a/_cffi1/support.py
+++ /dev/null
@@ -1,19 +0,0 @@
-import sys
-
-if sys.version_info < (3,):
-    __all__ = ['u']
-
-    class U(object):
-        def __add__(self, other):
-            return eval('u'+repr(other).replace(r'\\u', r'\u')
-                                       .replace(r'\\U', r'\U'))
-    u = U()
-    assert u+'a\x00b' == eval(r"u'a\x00b'")
-    assert u+'a\u1234b' == eval(r"u'a\u1234b'")
-    assert u+'a\U00012345b' == eval(r"u'a\U00012345b'")
-
-else:
-    __all__ = ['u', 'unicode', 'long']
-    u = ""
-    unicode = str
-    long = int
diff --git a/_cffi1/udir.py b/_cffi1/udir.py
deleted file mode 100644
--- a/_cffi1/udir.py
+++ /dev/null
@@ -1,3 +0,0 @@
-import py
-
-udir = py.path.local.make_numbered_dir(prefix = 'cffi1-')
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -5764,7 +5764,7 @@
 }
 
 static PyObject *b_init_cffi_1_0_external_module(PyObject *, PyObject *);
-/* forward, see _cffi1/cffi1_module.c */
+/* forward, see cffi1_module.c */
 
 
 static PyMethodDef FFIBackendMethods[] = {
@@ -5948,7 +5948,7 @@
 
 /************************************************************/
 
-#include "../_cffi1/cffi1_module.c"
+#include "cffi1_module.c"
 
 /************************************************************/
 
diff --git a/_cffi1/cdlopen.c b/c/cdlopen.c
rename from _cffi1/cdlopen.c
rename to c/cdlopen.c
diff --git a/_cffi1/cffi1_module.c b/c/cffi1_module.c
rename from _cffi1/cffi1_module.c
rename to c/cffi1_module.c
diff --git a/_cffi1/cgc.c b/c/cgc.c
rename from _cffi1/cgc.c
rename to c/cgc.c
diff --git a/_cffi1/cglob.c b/c/cglob.c
rename from _cffi1/cglob.c
rename to c/cglob.c
diff --git a/_cffi1/ffi_obj.c b/c/ffi_obj.c
rename from _cffi1/ffi_obj.c
rename to c/ffi_obj.c
diff --git a/_cffi1/lib_obj.c b/c/lib_obj.c
rename from _cffi1/lib_obj.c
rename to c/lib_obj.c
diff --git a/_cffi1/parse_c_type.c b/c/parse_c_type.c
rename from _cffi1/parse_c_type.c
rename to c/parse_c_type.c
--- a/_cffi1/parse_c_type.c
+++ b/c/parse_c_type.c
@@ -4,7 +4,7 @@
 #include <errno.h>
 
 #define _CFFI_INTERNAL
-#include "parse_c_type.h"
+#include "../cffi/parse_c_type.h"
 
 
 enum token_e {
diff --git a/_cffi1/realize_c_type.c b/c/realize_c_type.c
rename from _cffi1/realize_c_type.c
rename to c/realize_c_type.c
diff --git a/_cffi1/_cffi_include.h b/cffi/_cffi_include.h
rename from _cffi1/_cffi_include.h
rename to cffi/_cffi_include.h
diff --git a/cffi/api.py b/cffi/api.py
--- a/cffi/api.py
+++ b/cffi/api.py
@@ -486,7 +486,7 @@
 
     def distutils_extension(self, tmpdir='build', verbose=True):
         from distutils.dir_util import mkpath
-        from _cffi1 import recompile
+        from .recompiler import recompile
         #
         if not hasattr(self, '_assigned_source'):
             if hasattr(self, 'verifier'):     # fallback, 'tmpdir' ignored
@@ -506,7 +506,7 @@
         return ext
 
     def emit_c_code(self, filename):
-        from _cffi1 import recompile
+        from .recompiler import recompile
         #
         if not hasattr(self, '_assigned_source'):
             raise ValueError("set_source() must be called before emit_c_code()")
@@ -515,7 +515,7 @@
                   c_file=filename, call_c_compiler=False, **kwds)
 
     def compile(self, tmpdir='.'):
-        from _cffi1 import recompile
+        from .recompiler import recompile
         #
         if not hasattr(self, '_assigned_source'):
             raise ValueError("set_source() must be called before compile()")
diff --git a/_cffi1/cffi_opcode.py b/cffi/cffi_opcode.py
rename from _cffi1/cffi_opcode.py
rename to cffi/cffi_opcode.py
diff --git a/_cffi1/parse_c_type.h b/cffi/parse_c_type.h
rename from _cffi1/parse_c_type.h
rename to cffi/parse_c_type.h
diff --git a/_cffi1/recompiler.py b/cffi/recompiler.py
rename from _cffi1/recompiler.py
rename to cffi/recompiler.py
--- a/_cffi1/recompiler.py
+++ b/cffi/recompiler.py
@@ -933,8 +933,9 @@
     else:
         return ext, updated
 
-def verify(ffi, module_name, preamble, *args, **kwds):
-    from _cffi1.udir import udir
+def _verify(ffi, module_name, preamble, *args, **kwds):
+    # FOR TESTS ONLY
+    from testing.udir import udir
     import imp
     assert module_name not in sys.modules, "module name conflict: %r" % (
         module_name,)
diff --git a/_cffi1/setuptools_ext.py b/cffi/setuptools_ext.py
rename from _cffi1/setuptools_ext.py
rename to cffi/setuptools_ext.py
diff --git a/_cffi1/manual.c b/demo/manual.c
rename from _cffi1/manual.c
rename to demo/manual.c
diff --git a/_cffi1/manual2.py b/demo/manual2.py
rename from _cffi1/manual2.py
rename to demo/manual2.py
diff --git a/_cffi1/setup_manual.py b/demo/setup_manual.py
rename from _cffi1/setup_manual.py
rename to demo/setup_manual.py
diff --git a/testing/__init__.py b/testing/cffi0/__init__.py
copy from testing/__init__.py
copy to testing/cffi0/__init__.py
diff --git a/testing/backend_tests.py b/testing/cffi0/backend_tests.py
rename from testing/backend_tests.py
rename to testing/cffi0/backend_tests.py
diff --git a/testing/callback_in_thread.py b/testing/cffi0/callback_in_thread.py
rename from testing/callback_in_thread.py
rename to testing/cffi0/callback_in_thread.py
diff --git a/testing/snippets/distutils_module/setup.py b/testing/cffi0/snippets/distutils_module/setup.py
rename from testing/snippets/distutils_module/setup.py
rename to testing/cffi0/snippets/distutils_module/setup.py
diff --git a/testing/snippets/distutils_module/snip_basic_verify.py b/testing/cffi0/snippets/distutils_module/snip_basic_verify.py
rename from testing/snippets/distutils_module/snip_basic_verify.py
rename to testing/cffi0/snippets/distutils_module/snip_basic_verify.py
diff --git a/testing/snippets/distutils_package_1/setup.py b/testing/cffi0/snippets/distutils_package_1/setup.py
rename from testing/snippets/distutils_package_1/setup.py
rename to testing/cffi0/snippets/distutils_package_1/setup.py
diff --git a/testing/snippets/distutils_package_1/snip_basic_verify1/__init__.py b/testing/cffi0/snippets/distutils_package_1/snip_basic_verify1/__init__.py
rename from testing/snippets/distutils_package_1/snip_basic_verify1/__init__.py
rename to testing/cffi0/snippets/distutils_package_1/snip_basic_verify1/__init__.py
diff --git a/testing/snippets/distutils_package_2/setup.py b/testing/cffi0/snippets/distutils_package_2/setup.py
rename from testing/snippets/distutils_package_2/setup.py
rename to testing/cffi0/snippets/distutils_package_2/setup.py
diff --git a/testing/snippets/distutils_package_2/snip_basic_verify2/__init__.py b/testing/cffi0/snippets/distutils_package_2/snip_basic_verify2/__init__.py
rename from testing/snippets/distutils_package_2/snip_basic_verify2/__init__.py
rename to testing/cffi0/snippets/distutils_package_2/snip_basic_verify2/__init__.py
diff --git a/testing/snippets/infrastructure/setup.py b/testing/cffi0/snippets/infrastructure/setup.py
rename from testing/snippets/infrastructure/setup.py
rename to testing/cffi0/snippets/infrastructure/setup.py
diff --git a/testing/snippets/infrastructure/snip_infrastructure/__init__.py b/testing/cffi0/snippets/infrastructure/snip_infrastructure/__init__.py
rename from testing/snippets/infrastructure/snip_infrastructure/__init__.py
rename to testing/cffi0/snippets/infrastructure/snip_infrastructure/__init__.py
diff --git a/testing/snippets/setuptools_module/setup.py b/testing/cffi0/snippets/setuptools_module/setup.py
rename from testing/snippets/setuptools_module/setup.py
rename to testing/cffi0/snippets/setuptools_module/setup.py
diff --git a/testing/snippets/setuptools_module/snip_setuptools_verify.py b/testing/cffi0/snippets/setuptools_module/snip_setuptools_verify.py
rename from testing/snippets/setuptools_module/snip_setuptools_verify.py
rename to testing/cffi0/snippets/setuptools_module/snip_setuptools_verify.py
diff --git a/testing/snippets/setuptools_package_1/setup.py b/testing/cffi0/snippets/setuptools_package_1/setup.py
rename from testing/snippets/setuptools_package_1/setup.py
rename to testing/cffi0/snippets/setuptools_package_1/setup.py
diff --git a/testing/snippets/setuptools_package_1/snip_setuptools_verify1/__init__.py b/testing/cffi0/snippets/setuptools_package_1/snip_setuptools_verify1/__init__.py
rename from testing/snippets/setuptools_package_1/snip_setuptools_verify1/__init__.py
rename to testing/cffi0/snippets/setuptools_package_1/snip_setuptools_verify1/__init__.py
diff --git a/testing/snippets/setuptools_package_2/setup.py b/testing/cffi0/snippets/setuptools_package_2/setup.py
rename from testing/snippets/setuptools_package_2/setup.py
rename to testing/cffi0/snippets/setuptools_package_2/setup.py
diff --git a/testing/snippets/setuptools_package_2/snip_setuptools_verify2/__init__.py b/testing/cffi0/snippets/setuptools_package_2/snip_setuptools_verify2/__init__.py
rename from testing/snippets/setuptools_package_2/snip_setuptools_verify2/__init__.py
rename to testing/cffi0/snippets/setuptools_package_2/snip_setuptools_verify2/__init__.py
diff --git a/testing/test_cdata.py b/testing/cffi0/test_cdata.py
rename from testing/test_cdata.py
rename to testing/cffi0/test_cdata.py
diff --git a/testing/test_ctypes.py b/testing/cffi0/test_ctypes.py
rename from testing/test_ctypes.py
rename to testing/cffi0/test_ctypes.py
--- a/testing/test_ctypes.py
+++ b/testing/cffi0/test_ctypes.py
@@ -1,5 +1,5 @@
 import py, sys
-from testing import backend_tests
+from testing.cffi0 import backend_tests
 from cffi.backend_ctypes import CTypesBackend
 
 
diff --git a/testing/test_ffi_backend.py b/testing/cffi0/test_ffi_backend.py
rename from testing/test_ffi_backend.py
rename to testing/cffi0/test_ffi_backend.py
--- a/testing/test_ffi_backend.py
+++ b/testing/cffi0/test_ffi_backend.py
@@ -1,6 +1,6 @@
 import py, sys, platform
 import pytest
-from testing import backend_tests, test_function, test_ownlib
+from testing.cffi0 import backend_tests, test_function, test_ownlib
 from cffi import FFI
 import _cffi_backend
 
diff --git a/testing/test_function.py b/testing/cffi0/test_function.py
rename from testing/test_function.py
rename to testing/cffi0/test_function.py
diff --git a/testing/test_model.py b/testing/cffi0/test_model.py
rename from testing/test_model.py
rename to testing/cffi0/test_model.py
diff --git a/testing/test_ownlib.py b/testing/cffi0/test_ownlib.py
rename from testing/test_ownlib.py
rename to testing/cffi0/test_ownlib.py
diff --git a/testing/test_parsing.py b/testing/cffi0/test_parsing.py
rename from testing/test_parsing.py
rename to testing/cffi0/test_parsing.py
diff --git a/testing/test_platform.py b/testing/cffi0/test_platform.py
rename from testing/test_platform.py
rename to testing/cffi0/test_platform.py
diff --git a/testing/test_unicode_literals.py b/testing/cffi0/test_unicode_literals.py
rename from testing/test_unicode_literals.py
rename to testing/cffi0/test_unicode_literals.py
diff --git a/testing/test_verify.py b/testing/cffi0/test_verify.py
rename from testing/test_verify.py
rename to testing/cffi0/test_verify.py
diff --git a/testing/test_verify2.py b/testing/cffi0/test_verify2.py
rename from testing/test_verify2.py
rename to testing/cffi0/test_verify2.py
diff --git a/testing/test_version.py b/testing/cffi0/test_version.py
rename from testing/test_version.py
rename to testing/cffi0/test_version.py
diff --git a/testing/test_vgen.py b/testing/cffi0/test_vgen.py
rename from testing/test_vgen.py
rename to testing/cffi0/test_vgen.py
diff --git a/testing/test_vgen2.py b/testing/cffi0/test_vgen2.py
rename from testing/test_vgen2.py
rename to testing/cffi0/test_vgen2.py
diff --git a/testing/test_zdistutils.py b/testing/cffi0/test_zdistutils.py
rename from testing/test_zdistutils.py
rename to testing/cffi0/test_zdistutils.py
diff --git a/testing/test_zintegration.py b/testing/cffi0/test_zintegration.py
rename from testing/test_zintegration.py
rename to testing/cffi0/test_zintegration.py
diff --git a/testing/cffi1/__init__.py b/testing/cffi1/__init__.py
new file mode 100644
diff --git a/_cffi1/test_cffi_binary.py b/testing/cffi1/test_cffi_binary.py
rename from _cffi1/test_cffi_binary.py
rename to testing/cffi1/test_cffi_binary.py
diff --git a/_cffi1/test_dlopen.py b/testing/cffi1/test_dlopen.py
rename from _cffi1/test_dlopen.py
rename to testing/cffi1/test_dlopen.py
diff --git a/_cffi1/test_ffi_obj.py b/testing/cffi1/test_ffi_obj.py
rename from _cffi1/test_ffi_obj.py
rename to testing/cffi1/test_ffi_obj.py
diff --git a/_cffi1/test_new_ffi_1.py b/testing/cffi1/test_new_ffi_1.py
rename from _cffi1/test_new_ffi_1.py
rename to testing/cffi1/test_new_ffi_1.py
--- a/_cffi1/test_new_ffi_1.py
+++ b/testing/cffi1/test_new_ffi_1.py
@@ -2,9 +2,10 @@
 import platform, imp
 import sys, os, ctypes
 import cffi
-from .udir import udir
-from .recompiler import recompile
-from .support import *
+from testing.udir import udir
+from testing.support import *
+from cffi.recompiler import recompile
+from cffi.cffi_opcode import PRIMITIVE_TO_INDEX
 
 SIZE_OF_INT   = ctypes.sizeof(ctypes.c_int)
 SIZE_OF_LONG  = ctypes.sizeof(ctypes.c_long)
@@ -1596,7 +1597,6 @@
         assert list(a) == [10000, 20500, 30000]
 
     def test_all_primitives(self):
-        from .cffi_opcode import PRIMITIVE_TO_INDEX
         assert set(PRIMITIVE_TO_INDEX) == set([
             "char",
             "short",
diff --git a/_cffi1/test_parse_c_type.py b/testing/cffi1/test_parse_c_type.py
rename from _cffi1/test_parse_c_type.py
rename to testing/cffi1/test_parse_c_type.py
--- a/_cffi1/test_parse_c_type.py
+++ b/testing/cffi1/test_parse_c_type.py
@@ -1,13 +1,13 @@
 import sys, re, os, py
 import cffi
-from . import cffi_opcode
+from cffi import cffi_opcode
 
-local_dir = os.path.dirname(__file__)
+cffi_dir = os.path.dirname(cffi_opcode.__file__)
 
 r_macro = re.compile(r"#define \w+[(][^\n]*|#include [^\n]*")
 r_define = re.compile(r"(#define \w+) [^\n]*")
 r_ifdefs = re.compile(r"(#ifdef |#endif)[^\n]*")
-header = open(os.path.join(local_dir, 'parse_c_type.h')).read()
+header = open(os.path.join(cffi_dir, 'parse_c_type.h')).read()
 header = r_macro.sub(r"", header)
 header = r_define.sub(r"\1 ...", header)
 header = r_ifdefs.sub(r"", header)
@@ -15,8 +15,9 @@
 ffi = cffi.FFI()
 ffi.cdef(header)
 
-lib = ffi.verify(open(os.path.join(local_dir, 'parse_c_type.c')).read(),
-                 include_dirs=[local_dir])
+lib = ffi.verify(
+        open(os.path.join(cffi_dir, '..', 'c', 'parse_c_type.c')).read(),
+        include_dirs=[cffi_dir])
 
 class ParseError(Exception):
     pass
diff --git a/_cffi1/test_realize_c_type.py b/testing/cffi1/test_realize_c_type.py
rename from _cffi1/test_realize_c_type.py
rename to testing/cffi1/test_realize_c_type.py
--- a/_cffi1/test_realize_c_type.py
+++ b/testing/cffi1/test_realize_c_type.py
@@ -1,4 +1,5 @@
 import py
+from cffi import cffi_opcode
 
 
 def check(input, expected_output=None, expected_ffi_error=False):
@@ -43,6 +44,5 @@
     check("int(*)(long[5])", "int(*)(long *)")
 
 def test_all_primitives():
-    from . import cffi_opcode
     for name in cffi_opcode.PRIMITIVE_TO_INDEX:
         check(name, name)
diff --git a/_cffi1/test_recompiler.py b/testing/cffi1/test_recompiler.py
rename from _cffi1/test_recompiler.py
rename to testing/cffi1/test_recompiler.py
--- a/_cffi1/test_recompiler.py
+++ b/testing/cffi1/test_recompiler.py
@@ -1,8 +1,8 @@
 import sys, os, py
 from cffi import FFI, VerificationError
-from _cffi1 import recompiler
-from _cffi1.udir import udir
-from _cffi1.support import u
+from cffi import recompiler
+from testing.udir import udir
+from testing.support import u
 
 
 def check_type_table(input, expected_output, included=None):
@@ -18,7 +18,7 @@
 
 def verify(ffi, module_name, *args, **kwds):
     kwds.setdefault('undef_macros', ['NDEBUG'])
-    return recompiler.verify(ffi, '_CFFI_' + module_name, *args, **kwds)
+    return recompiler._verify(ffi, '_CFFI_' + module_name, *args, **kwds)
 
 
 def test_type_table_func():
diff --git a/_cffi1/test_unicode_literals.py b/testing/cffi1/test_unicode_literals.py
rename from _cffi1/test_unicode_literals.py
rename to testing/cffi1/test_unicode_literals.py
diff --git a/_cffi1/test_verify1.py b/testing/cffi1/test_verify1.py
rename from _cffi1/test_verify1.py
rename to testing/cffi1/test_verify1.py
--- a/_cffi1/test_verify1.py
+++ b/testing/cffi1/test_verify1.py
@@ -1,7 +1,7 @@
 import sys, math, py
 from cffi import FFI, VerificationError, VerificationMissing, model
-from . import recompiler
-from .support import *
+from cffi import recompiler
+from testing.support import *
 import _cffi_backend
 
 lib_m = ['m']
@@ -29,10 +29,10 @@
 
     def verify(self, preamble='', *args, **kwds):
         FFI._verify_counter += 1
-        return recompiler.verify(self, 'verify%d' % FFI._verify_counter,
-                                 preamble, *args,
-                                 extra_compile_args=self._extra_compile_args,
-                                 **kwds)
+        return recompiler._verify(self, 'verify%d' % FFI._verify_counter,
+                                  preamble, *args,
+                                  extra_compile_args=self._extra_compile_args,
+                                  **kwds)
 
 class FFI_warnings_not_error(FFI):
     _extra_compile_args = []


More information about the pypy-commit mailing list