Author: Brian Kearns <[email protected]>
Branch:
Changeset: r67393:a8cd97cc4eb3
Date: 2013-10-15 05:22 -0400
http://bitbucket.org/pypy/pypy/changeset/a8cd97cc4eb3/
Log: move numpypy get_include to match numpy
diff --git a/lib_pypy/numpypy/__init__.py b/lib_pypy/numpypy/__init__.py
--- a/lib_pypy/numpypy/__init__.py
+++ b/lib_pypy/numpypy/__init__.py
@@ -9,40 +9,7 @@
__version__ = '1.7.0'
-import os
-def get_include():
- """
- Return the directory that contains the NumPy \\*.h header files.
-
- Extension modules that need to compile against NumPy should use this
- function to locate the appropriate include directory.
-
- Notes
- -----
- When using ``distutils``, for example in ``setup.py``.
- ::
-
- import numpy as np
- ...
- Extension('extension_name', ...
- include_dirs=[np.get_include()])
- ...
-
- """
- try:
- import numpy
- except:
- # running from pypy source directory
- head, tail = os.path.split(os.path.dirname(os.path.abspath(__file__)))
- return os.path.join(head, '../include')
- else:
- # using installed numpy core headers
- import numpy.core as core
- d = os.path.join(os.path.dirname(core.__file__), 'include')
- return d
-
-
-__all__ = ['__version__', 'get_include']
+__all__ = ['__version__']
__all__ += core.__all__
__all__ += lib.__all__
diff --git a/lib_pypy/numpypy/lib/__init__.py b/lib_pypy/numpypy/lib/__init__.py
--- a/lib_pypy/numpypy/lib/__init__.py
+++ b/lib_pypy/numpypy/lib/__init__.py
@@ -5,8 +5,10 @@
from .function_base import *
from .shape_base import *
from .twodim_base import *
+from .utils import *
__all__ = ['math']
__all__ += function_base.__all__
__all__ += shape_base.__all__
__all__ += twodim_base.__all__
+__all__ += utils.__all__
diff --git a/lib_pypy/numpypy/lib/utils.py b/lib_pypy/numpypy/lib/utils.py
new file mode 100644
--- /dev/null
+++ b/lib_pypy/numpypy/lib/utils.py
@@ -0,0 +1,34 @@
+import os
+
+__all__ = ['get_include']
+
+def get_include():
+ """
+ Return the directory that contains the NumPy \\*.h header files.
+
+ Extension modules that need to compile against NumPy should use this
+ function to locate the appropriate include directory.
+
+ Notes
+ -----
+ When using ``distutils``, for example in ``setup.py``.
+ ::
+
+ import numpy as np
+ ...
+ Extension('extension_name', ...
+ include_dirs=[np.get_include()])
+ ...
+
+ """
+ try:
+ import numpy
+ except:
+ # running from pypy source directory
+ head, tail = os.path.split(os.path.dirname(os.path.abspath(__file__)))
+ return os.path.join(head, '../include')
+ else:
+ # using installed numpy core headers
+ import numpy.core as core
+ d = os.path.join(os.path.dirname(core.__file__), 'include')
+ return d
diff --git a/pypy/module/test_lib_pypy/numpypy/test_numpy.py
b/pypy/module/test_lib_pypy/numpypy/test_numpy.py
--- a/pypy/module/test_lib_pypy/numpypy/test_numpy.py
+++ b/pypy/module/test_lib_pypy/numpypy/test_numpy.py
@@ -59,10 +59,9 @@
assert 'numpypy' not in dir(numpypy)
def test_get_include(self):
- import sys
+ import numpypy, os, sys
+ assert 'get_include' in dir(numpypy)
+ path = numpypy.get_include()
if not hasattr(sys, 'pypy_translation_info'):
skip("pypy white-box test")
- import numpypy, os
- assert 'get_include' in dir(numpypy)
- path = numpypy.get_include()
assert os.path.exists(path + '/numpy/arrayobject.h')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit