Commit 1d66ca72 authored by Robert Bradshaw's avatar Robert Bradshaw

Revert "More hacks for numpy 1.7: Check for Includes/numpy.pxd"

This reverts commit 6f2271d2.

Conflicts:

	Cython/Compiler/ParseTreeTransforms.py
parent 2e8e56c8
...@@ -34,8 +34,6 @@ import Symtab ...@@ -34,8 +34,6 @@ import Symtab
import Options import Options
from Cython import Utils from Cython import Utils
from Annotate import AnnotationItem from Annotate import AnnotationItem
from NumpySupport import numpy_transform_attribute_node, \
should_apply_numpy_hack
from Cython.Debugging import print_call_chain from Cython.Debugging import print_call_chain
from DebugFlags import debug_disposal_code, debug_temp_alloc, \ from DebugFlags import debug_disposal_code, debug_temp_alloc, \
...@@ -4461,8 +4459,10 @@ class AttributeNode(ExprNode): ...@@ -4461,8 +4459,10 @@ class AttributeNode(ExprNode):
# attribute. # attribute.
pass pass
# NumPy hack # NumPy hack
if (getattr(self.obj, 'type', None) and obj_type.is_extension_type if (getattr(self.obj, 'type', None) and
and should_apply_numpy_hack(obj_type)): obj_type.is_extension_type and
obj_type.objstruct_cname == 'PyArrayObject'):
from NumpySupport import numpy_transform_attribute_node
replacement_node = numpy_transform_attribute_node(self) replacement_node = numpy_transform_attribute_node(self)
# Since we can't actually replace our node yet, we only grasp its # Since we can't actually replace our node yet, we only grasp its
# type, and then the replacement happens in # type, and then the replacement happens in
...@@ -4470,6 +4470,7 @@ class AttributeNode(ExprNode): ...@@ -4470,6 +4470,7 @@ class AttributeNode(ExprNode):
self.type = replacement_node.type self.type = replacement_node.type
if replacement_node is not self: if replacement_node is not self:
return return
# If we get here, the base object is not a struct/union/extension # If we get here, the base object is not a struct/union/extension
# type, or it is an extension type and the attribute is either not # type, or it is an extension type and the attribute is either not
# declared or is declared as a Python method. Treat it as a Python # declared or is declared as a Python method. Treat it as a Python
......
...@@ -24,10 +24,6 @@ module_name_pattern = re.compile(r"[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_ ...@@ -24,10 +24,6 @@ module_name_pattern = re.compile(r"[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_
verbose = 0 verbose = 0
standard_include_path = os.path.abspath(os.path.normpath(
os.path.join(os.path.dirname(__file__), os.path.pardir, 'Includes')))
class CompilationData(object): class CompilationData(object):
# Bundles the information that is passed from transform to transform. # Bundles the information that is passed from transform to transform.
# (For now, this is only) # (For now, this is only)
...@@ -74,6 +70,8 @@ class Context(object): ...@@ -74,6 +70,8 @@ class Context(object):
self.pxds = {} # full name -> node tree self.pxds = {} # full name -> node tree
standard_include_path = os.path.abspath(os.path.normpath(
os.path.join(os.path.dirname(__file__), os.path.pardir, 'Includes')))
self.include_directories = include_directories + [standard_include_path] self.include_directories = include_directories + [standard_include_path]
self.set_language_level(language_level) self.set_language_level(language_level)
......
...@@ -2,24 +2,13 @@ ...@@ -2,24 +2,13 @@
# the NumPy ABI changed so that the shape, ndim, strides, etc. fields were # the NumPy ABI changed so that the shape, ndim, strides, etc. fields were
# no longer available, however the use of these were so entrenched in # no longer available, however the use of these were so entrenched in
# Cython codes # Cython codes
import os
import PyrexTypes
import ExprNodes
from StringEncoding import EncodedString from StringEncoding import EncodedString
def should_apply_numpy_hack(obj_type):
if not obj_type.is_extension_type or obj_type.objstruct_cname != 'PyArrayObject':
return False
from Scanning import FileSourceDescriptor
from Main import standard_include_path
type_source = obj_type.pos[0]
if isinstance(type_source, FileSourceDescriptor):
type_source_path = os.path.abspath(os.path.normpath(type_source.filename))
return type_source_path == os.path.join(standard_include_path, 'numpy.pxd')
else:
return False
def numpy_transform_attribute_node(node): def numpy_transform_attribute_node(node):
import PyrexTypes
import ExprNodes
assert isinstance(node, ExprNodes.AttributeNode) assert isinstance(node, ExprNodes.AttributeNode)
if node.obj.type.objstruct_cname != 'PyArrayObject': if node.obj.type.objstruct_cname != 'PyArrayObject':
......
...@@ -18,8 +18,7 @@ from Cython.Compiler.TreeFragment import TreeFragment ...@@ -18,8 +18,7 @@ from Cython.Compiler.TreeFragment import TreeFragment
from Cython.Compiler.StringEncoding import EncodedString from Cython.Compiler.StringEncoding import EncodedString
from Cython.Compiler.Errors import error, warning, CompileError, InternalError from Cython.Compiler.Errors import error, warning, CompileError, InternalError
from Cython.Compiler.Code import UtilityCode from Cython.Compiler.Code import UtilityCode
from Cython.Compiler.NumpySupport import (should_apply_numpy_hack,
numpy_transform_attribute_node)
import copy import copy
...@@ -1798,8 +1797,8 @@ class AnalyseExpressionsTransform(CythonTransform): ...@@ -1798,8 +1797,8 @@ class AnalyseExpressionsTransform(CythonTransform):
#print node.dump() #print node.dump()
#return node #return node
type = node.obj.type type = node.obj.type
if (not node.type.is_error and type.is_extension_type and if type.is_extension_type and type.objstruct_cname == 'PyArrayObject':
should_apply_numpy_hack(type)): from NumpySupport import numpy_transform_attribute_node
node = numpy_transform_attribute_node(node) node = numpy_transform_attribute_node(node)
self.visitchildren(node) self.visitchildren(node)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment