From: Lisandro Dalcin Date: Fri, 11 Jun 2010 19:27:59 +0000 (-0300) Subject: move legacy pxd files to Cython/Includes/Deprecated X-Git-Tag: 0.13.beta0~46 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0d04f2bba4c491b7255126c2c32e12fa4098d741;p=cython.git move legacy pxd files to Cython/Includes/Deprecated --HG-- rename : Cython/Includes/python.pxd => Cython/Includes/Deprecated/python.pxd rename : Cython/Includes/python2.5.pxd => Cython/Includes/Deprecated/python2.5.pxd rename : Cython/Includes/python_bool.pxd => Cython/Includes/Deprecated/python_bool.pxd rename : Cython/Includes/python_buffer.pxd => Cython/Includes/Deprecated/python_buffer.pxd rename : Cython/Includes/python_bytes.pxd => Cython/Includes/Deprecated/python_bytes.pxd rename : Cython/Includes/python_cobject.pxd => Cython/Includes/Deprecated/python_cobject.pxd rename : Cython/Includes/python_complex.pxd => Cython/Includes/Deprecated/python_complex.pxd rename : Cython/Includes/python_dict.pxd => Cython/Includes/Deprecated/python_dict.pxd rename : Cython/Includes/python_exc.pxd => Cython/Includes/Deprecated/python_exc.pxd rename : Cython/Includes/python_float.pxd => Cython/Includes/Deprecated/python_float.pxd rename : Cython/Includes/python_function.pxd => Cython/Includes/Deprecated/python_function.pxd rename : Cython/Includes/python_getargs.pxd => Cython/Includes/Deprecated/python_getargs.pxd rename : Cython/Includes/python_instance.pxd => Cython/Includes/Deprecated/python_instance.pxd rename : Cython/Includes/python_int.pxd => Cython/Includes/Deprecated/python_int.pxd rename : Cython/Includes/python_iterator.pxd => Cython/Includes/Deprecated/python_iterator.pxd rename : Cython/Includes/python_list.pxd => Cython/Includes/Deprecated/python_list.pxd rename : Cython/Includes/python_long.pxd => Cython/Includes/Deprecated/python_long.pxd rename : Cython/Includes/python_mapping.pxd => Cython/Includes/Deprecated/python_mapping.pxd rename : Cython/Includes/python_mem.pxd => Cython/Includes/Deprecated/python_mem.pxd rename : Cython/Includes/python_method.pxd => Cython/Includes/Deprecated/python_method.pxd rename : Cython/Includes/python_module.pxd => Cython/Includes/Deprecated/python_module.pxd rename : Cython/Includes/python_number.pxd => Cython/Includes/Deprecated/python_number.pxd rename : Cython/Includes/python_object.pxd => Cython/Includes/Deprecated/python_object.pxd rename : Cython/Includes/python_oldbuffer.pxd => Cython/Includes/Deprecated/python_oldbuffer.pxd rename : Cython/Includes/python_pycapsule.pxd => Cython/Includes/Deprecated/python_pycapsule.pxd rename : Cython/Includes/python_ref.pxd => Cython/Includes/Deprecated/python_ref.pxd rename : Cython/Includes/python_sequence.pxd => Cython/Includes/Deprecated/python_sequence.pxd rename : Cython/Includes/python_set.pxd => Cython/Includes/Deprecated/python_set.pxd rename : Cython/Includes/python_string.pxd => Cython/Includes/Deprecated/python_string.pxd rename : Cython/Includes/python_tuple.pxd => Cython/Includes/Deprecated/python_tuple.pxd rename : Cython/Includes/python_type.pxd => Cython/Includes/Deprecated/python_type.pxd rename : Cython/Includes/python_unicode.pxd => Cython/Includes/Deprecated/python_unicode.pxd rename : Cython/Includes/python_version.pxd => Cython/Includes/Deprecated/python_version.pxd rename : Cython/Includes/python_weakref.pxd => Cython/Includes/Deprecated/python_weakref.pxd rename : Cython/Includes/stdio.pxd => Cython/Includes/Deprecated/stdio.pxd rename : Cython/Includes/stdlib.pxd => Cython/Includes/Deprecated/stdlib.pxd rename : Cython/Includes/stl.pxd => Cython/Includes/Deprecated/stl.pxd --- diff --git a/Cython/Compiler/Main.py b/Cython/Compiler/Main.py index 74e33b13..b06b116d 100644 --- a/Cython/Compiler/Main.py +++ b/Cython/Compiler/Main.py @@ -19,7 +19,7 @@ import Errors import Parsing import Version from Scanning import PyrexScanner, FileSourceDescriptor -from Errors import PyrexError, CompileError, InternalError, error +from Errors import PyrexError, CompileError, InternalError, error, warning from Symtab import BuiltinScope, ModuleScope from Cython import Utils from Cython.Utils import open_new_file, replace_suffix @@ -321,7 +321,27 @@ class Context(object): # the directory containing the source file is searched first # for a dotted filename, and its containing package root # directory is searched first for a non-dotted filename. - return self.search_include_directories(qualified_name, ".pxd", pos) + pxd = self.search_include_directories(qualified_name, ".pxd", pos) + if pxd is None: # XXX Keep this until Includes/Deprecated is removed + if (qualified_name.startswith('python') or + qualified_name in ('stdlib', 'stdio', 'stl')): + standard_include_path = os.path.abspath(os.path.normpath( + os.path.join(os.path.dirname(__file__), os.path.pardir, 'Includes'))) + deprecated_include_path = os.path.join(standard_include_path, 'Deprecated') + self.include_directories.append(deprecated_include_path) + try: + pxd = self.search_include_directories(qualified_name, ".pxd", pos) + finally: + self.include_directories.pop() + if pxd: + name = qualified_name + if name.startswith('python'): + warning(pos, "'%s' is deprecated, use 'cpython'" % name, 1) + elif name in ('stdlib', 'stdio'): + warning(pos, "'%s' is deprecated, use 'libc.%s'" % (name, name), 1) + elif name in ('stl'): + warning(pos, "'%s' is deprecated, use 'libcpp.*.*'" % name, 1) + return pxd def find_pyx_file(self, qualified_name, pos): # Search include path for the .pyx file corresponding to the diff --git a/Cython/Includes/python.pxd b/Cython/Includes/Deprecated/python.pxd similarity index 100% rename from Cython/Includes/python.pxd rename to Cython/Includes/Deprecated/python.pxd diff --git a/Cython/Includes/python2.5.pxd b/Cython/Includes/Deprecated/python2.5.pxd similarity index 100% rename from Cython/Includes/python2.5.pxd rename to Cython/Includes/Deprecated/python2.5.pxd diff --git a/Cython/Includes/python_bool.pxd b/Cython/Includes/Deprecated/python_bool.pxd similarity index 100% rename from Cython/Includes/python_bool.pxd rename to Cython/Includes/Deprecated/python_bool.pxd diff --git a/Cython/Includes/python_buffer.pxd b/Cython/Includes/Deprecated/python_buffer.pxd similarity index 100% rename from Cython/Includes/python_buffer.pxd rename to Cython/Includes/Deprecated/python_buffer.pxd diff --git a/Cython/Includes/python_bytes.pxd b/Cython/Includes/Deprecated/python_bytes.pxd similarity index 100% rename from Cython/Includes/python_bytes.pxd rename to Cython/Includes/Deprecated/python_bytes.pxd diff --git a/Cython/Includes/python_cobject.pxd b/Cython/Includes/Deprecated/python_cobject.pxd similarity index 100% rename from Cython/Includes/python_cobject.pxd rename to Cython/Includes/Deprecated/python_cobject.pxd diff --git a/Cython/Includes/python_complex.pxd b/Cython/Includes/Deprecated/python_complex.pxd similarity index 100% rename from Cython/Includes/python_complex.pxd rename to Cython/Includes/Deprecated/python_complex.pxd diff --git a/Cython/Includes/python_dict.pxd b/Cython/Includes/Deprecated/python_dict.pxd similarity index 100% rename from Cython/Includes/python_dict.pxd rename to Cython/Includes/Deprecated/python_dict.pxd diff --git a/Cython/Includes/python_exc.pxd b/Cython/Includes/Deprecated/python_exc.pxd similarity index 100% rename from Cython/Includes/python_exc.pxd rename to Cython/Includes/Deprecated/python_exc.pxd diff --git a/Cython/Includes/python_float.pxd b/Cython/Includes/Deprecated/python_float.pxd similarity index 100% rename from Cython/Includes/python_float.pxd rename to Cython/Includes/Deprecated/python_float.pxd diff --git a/Cython/Includes/python_function.pxd b/Cython/Includes/Deprecated/python_function.pxd similarity index 100% rename from Cython/Includes/python_function.pxd rename to Cython/Includes/Deprecated/python_function.pxd diff --git a/Cython/Includes/python_getargs.pxd b/Cython/Includes/Deprecated/python_getargs.pxd similarity index 100% rename from Cython/Includes/python_getargs.pxd rename to Cython/Includes/Deprecated/python_getargs.pxd diff --git a/Cython/Includes/python_instance.pxd b/Cython/Includes/Deprecated/python_instance.pxd similarity index 100% rename from Cython/Includes/python_instance.pxd rename to Cython/Includes/Deprecated/python_instance.pxd diff --git a/Cython/Includes/python_int.pxd b/Cython/Includes/Deprecated/python_int.pxd similarity index 100% rename from Cython/Includes/python_int.pxd rename to Cython/Includes/Deprecated/python_int.pxd diff --git a/Cython/Includes/python_iterator.pxd b/Cython/Includes/Deprecated/python_iterator.pxd similarity index 100% rename from Cython/Includes/python_iterator.pxd rename to Cython/Includes/Deprecated/python_iterator.pxd diff --git a/Cython/Includes/python_list.pxd b/Cython/Includes/Deprecated/python_list.pxd similarity index 100% rename from Cython/Includes/python_list.pxd rename to Cython/Includes/Deprecated/python_list.pxd diff --git a/Cython/Includes/python_long.pxd b/Cython/Includes/Deprecated/python_long.pxd similarity index 100% rename from Cython/Includes/python_long.pxd rename to Cython/Includes/Deprecated/python_long.pxd diff --git a/Cython/Includes/python_mapping.pxd b/Cython/Includes/Deprecated/python_mapping.pxd similarity index 100% rename from Cython/Includes/python_mapping.pxd rename to Cython/Includes/Deprecated/python_mapping.pxd diff --git a/Cython/Includes/python_mem.pxd b/Cython/Includes/Deprecated/python_mem.pxd similarity index 100% rename from Cython/Includes/python_mem.pxd rename to Cython/Includes/Deprecated/python_mem.pxd diff --git a/Cython/Includes/python_method.pxd b/Cython/Includes/Deprecated/python_method.pxd similarity index 100% rename from Cython/Includes/python_method.pxd rename to Cython/Includes/Deprecated/python_method.pxd diff --git a/Cython/Includes/python_module.pxd b/Cython/Includes/Deprecated/python_module.pxd similarity index 100% rename from Cython/Includes/python_module.pxd rename to Cython/Includes/Deprecated/python_module.pxd diff --git a/Cython/Includes/python_number.pxd b/Cython/Includes/Deprecated/python_number.pxd similarity index 100% rename from Cython/Includes/python_number.pxd rename to Cython/Includes/Deprecated/python_number.pxd diff --git a/Cython/Includes/python_object.pxd b/Cython/Includes/Deprecated/python_object.pxd similarity index 100% rename from Cython/Includes/python_object.pxd rename to Cython/Includes/Deprecated/python_object.pxd diff --git a/Cython/Includes/python_oldbuffer.pxd b/Cython/Includes/Deprecated/python_oldbuffer.pxd similarity index 100% rename from Cython/Includes/python_oldbuffer.pxd rename to Cython/Includes/Deprecated/python_oldbuffer.pxd diff --git a/Cython/Includes/python_pycapsule.pxd b/Cython/Includes/Deprecated/python_pycapsule.pxd similarity index 100% rename from Cython/Includes/python_pycapsule.pxd rename to Cython/Includes/Deprecated/python_pycapsule.pxd diff --git a/Cython/Includes/python_ref.pxd b/Cython/Includes/Deprecated/python_ref.pxd similarity index 100% rename from Cython/Includes/python_ref.pxd rename to Cython/Includes/Deprecated/python_ref.pxd diff --git a/Cython/Includes/python_sequence.pxd b/Cython/Includes/Deprecated/python_sequence.pxd similarity index 100% rename from Cython/Includes/python_sequence.pxd rename to Cython/Includes/Deprecated/python_sequence.pxd diff --git a/Cython/Includes/python_set.pxd b/Cython/Includes/Deprecated/python_set.pxd similarity index 100% rename from Cython/Includes/python_set.pxd rename to Cython/Includes/Deprecated/python_set.pxd diff --git a/Cython/Includes/python_string.pxd b/Cython/Includes/Deprecated/python_string.pxd similarity index 100% rename from Cython/Includes/python_string.pxd rename to Cython/Includes/Deprecated/python_string.pxd diff --git a/Cython/Includes/python_tuple.pxd b/Cython/Includes/Deprecated/python_tuple.pxd similarity index 100% rename from Cython/Includes/python_tuple.pxd rename to Cython/Includes/Deprecated/python_tuple.pxd diff --git a/Cython/Includes/python_type.pxd b/Cython/Includes/Deprecated/python_type.pxd similarity index 100% rename from Cython/Includes/python_type.pxd rename to Cython/Includes/Deprecated/python_type.pxd diff --git a/Cython/Includes/python_unicode.pxd b/Cython/Includes/Deprecated/python_unicode.pxd similarity index 100% rename from Cython/Includes/python_unicode.pxd rename to Cython/Includes/Deprecated/python_unicode.pxd diff --git a/Cython/Includes/python_version.pxd b/Cython/Includes/Deprecated/python_version.pxd similarity index 100% rename from Cython/Includes/python_version.pxd rename to Cython/Includes/Deprecated/python_version.pxd diff --git a/Cython/Includes/python_weakref.pxd b/Cython/Includes/Deprecated/python_weakref.pxd similarity index 100% rename from Cython/Includes/python_weakref.pxd rename to Cython/Includes/Deprecated/python_weakref.pxd diff --git a/Cython/Includes/stdio.pxd b/Cython/Includes/Deprecated/stdio.pxd similarity index 100% rename from Cython/Includes/stdio.pxd rename to Cython/Includes/Deprecated/stdio.pxd diff --git a/Cython/Includes/stdlib.pxd b/Cython/Includes/Deprecated/stdlib.pxd similarity index 100% rename from Cython/Includes/stdlib.pxd rename to Cython/Includes/Deprecated/stdlib.pxd diff --git a/Cython/Includes/stl.pxd b/Cython/Includes/Deprecated/stl.pxd similarity index 100% rename from Cython/Includes/stl.pxd rename to Cython/Includes/Deprecated/stl.pxd diff --git a/Cython/Includes/cpython/object.pxd b/Cython/Includes/cpython/object.pxd index 5d434d90..de49492f 100644 --- a/Cython/Includes/cpython/object.pxd +++ b/Cython/Includes/cpython/object.pxd @@ -1,5 +1,5 @@ from cpython.ref cimport PyObject, PyTypeObject -from stdio cimport FILE +from libc.stdio cimport FILE cdef extern from "Python.h": diff --git a/Cython/Includes/numpy.pxd b/Cython/Includes/numpy.pxd index 862d8ac2..dd6da0c6 100644 --- a/Cython/Includes/numpy.pxd +++ b/Cython/Includes/numpy.pxd @@ -16,10 +16,10 @@ DEF _buffer_format_string_len = 255 -cimport python_buffer as pybuf -from python_ref cimport PyObject, Py_INCREF, Py_XDECREF -cimport stdlib -cimport stdio +cimport cpython.buffer as pybuf +from cpython cimport PyObject, Py_INCREF, Py_XDECREF +from libc cimport stdlib +from libc cimport stdio cdef extern from "Python.h": ctypedef int Py_intptr_t diff --git a/tests/compile/c_directives.pyx b/tests/compile/c_directives.pyx index 942ba90e..f2920011 100644 --- a/tests/compile/c_directives.pyx +++ b/tests/compile/c_directives.pyx @@ -6,7 +6,7 @@ print 3 -cimport python_dict as asadf, python_exc, cython as cy +cimport cython as cy def e(object[int, ndim=2] buf): print buf[3, 2] # no bc diff --git a/tests/compile/shipped_pxds.pyx b/tests/compile/shipped_pxds.pyx deleted file mode 100644 index 7392d03c..00000000 --- a/tests/compile/shipped_pxds.pyx +++ /dev/null @@ -1,34 +0,0 @@ -cimport python_bool -cimport python_buffer -cimport python_bytes -cimport python_cobject -cimport python_complex -cimport python_dict -cimport python_exc -cimport python_float -cimport python_function -cimport python_getargs -cimport python_instance -cimport python_int -cimport python_iterator -cimport python_list -cimport python_long -cimport python_mapping -cimport python_mem -cimport python_method -cimport python_module -cimport python_number -cimport python_object -cimport python -cimport python_pycapsule -cimport python_ref -cimport python_sequence -cimport python_set -cimport python_string -cimport python_tuple -cimport python_type -cimport python_unicode -cimport python_version -cimport python_weakref -cimport stdio -cimport stdlib diff --git a/tests/run/bufaccess.pyx b/tests/run/bufaccess.pyx index b6cdc8d8..bb7072b4 100644 --- a/tests/run/bufaccess.pyx +++ b/tests/run/bufaccess.pyx @@ -9,12 +9,12 @@ from __future__ import unicode_literals -cimport stdlib -cimport python_buffer -cimport stdio +from libc cimport stdlib +from libc cimport stdio +cimport cpython.buffer cimport cython -from python_ref cimport PyObject +from cpython cimport PyObject, Py_INCREF, Py_DECREF __test__ = {} @@ -871,7 +871,6 @@ def printbuf_td_h_double(object[td_h_double] buf, shape): # # Object access # -from python_ref cimport Py_INCREF, Py_DECREF def addref(*args): for item in args: Py_INCREF(item) def decref(*args): @@ -983,13 +982,13 @@ def buffer_cast_fails(object[char, cast=True] buf): available_flags = ( - ('FORMAT', python_buffer.PyBUF_FORMAT), - ('INDIRECT', python_buffer.PyBUF_INDIRECT), - ('ND', python_buffer.PyBUF_ND), - ('STRIDES', python_buffer.PyBUF_STRIDES), - ('C_CONTIGUOUS', python_buffer.PyBUF_C_CONTIGUOUS), - ('F_CONTIGUOUS', python_buffer.PyBUF_F_CONTIGUOUS), - ('WRITABLE', python_buffer.PyBUF_WRITABLE) + ('FORMAT', cpython.buffer.PyBUF_FORMAT), + ('INDIRECT', cpython.buffer.PyBUF_INDIRECT), + ('ND', cpython.buffer.PyBUF_ND), + ('STRIDES', cpython.buffer.PyBUF_STRIDES), + ('C_CONTIGUOUS', cpython.buffer.PyBUF_C_CONTIGUOUS), + ('F_CONTIGUOUS', cpython.buffer.PyBUF_F_CONTIGUOUS), + ('WRITABLE', cpython.buffer.PyBUF_WRITABLE) ) cdef class MockBuffer: diff --git a/tests/run/buffmt.pyx b/tests/run/buffmt.pyx index 3d740d61..c4ec4c0c 100644 --- a/tests/run/buffmt.pyx +++ b/tests/run/buffmt.pyx @@ -7,7 +7,7 @@ def testcase(func): __test__[func.__name__] = func.__doc__ return func -cimport stdlib +from libc cimport stdlib def little_endian(): cdef unsigned int n = 1 diff --git a/tests/run/cython_includes.pyx b/tests/run/cython_includes.pyx index ddaec586..40fdeeaa 100644 --- a/tests/run/cython_includes.pyx +++ b/tests/run/cython_includes.pyx @@ -1,7 +1,7 @@ from libc.stdio cimport sprintf -from python cimport PyType_Check -from python_type cimport PyType_Check as PyType_Check2 +from cpython cimport PyType_Check +from cpython cimport PyType_Check as PyType_Check2 from cpython.type cimport PyType_Check as PyType_Check3 def libc_cimports(): diff --git a/tests/run/inplace.pyx b/tests/run/inplace.pyx index 7ae65753..99acc351 100644 --- a/tests/run/inplace.pyx +++ b/tests/run/inplace.pyx @@ -30,7 +30,7 @@ def h(double a, double b): a *= b return a -cimport stdlib +from libc cimport stdlib def arrays(): """ diff --git a/tests/run/r_pythonapi.pyx b/tests/run/r_pythonapi.pyx index ead4ff33..8557d17f 100644 --- a/tests/run/r_pythonapi.pyx +++ b/tests/run/r_pythonapi.pyx @@ -11,7 +11,7 @@ if sys.version_info[0] >= 3: cdef extern from "string.h": void memcpy(char *d, char *s, int n) -from python_unicode cimport PyUnicode_DecodeUTF8 +from cpython cimport PyUnicode_DecodeUTF8 def spam(): cdef char buf[12]