Commit f5b89afa authored by Robert Bradshaw's avatar Robert Bradshaw

Rework import warnings.

parent 14b2c1da
...@@ -17,24 +17,30 @@ from distutils.command import build_ext as _build_ext ...@@ -17,24 +17,30 @@ from distutils.command import build_ext as _build_ext
from distutils import sysconfig from distutils import sysconfig
import warnings import warnings
try:
frames = inspect.getouterframes(inspect.currentframe(), 2)
from_setuptools = 'setuptools/extension.py' in frames[2][1]
from_pyximport = 'pyximport/pyxbuild.py' in frames[1][1]
from_cy_buildext = 'Cython/Distutils/build_ext.py' in frames[1][1]
except Exception:
from_setuptools = from_pyximport = from_cy_buildext = False
if not from_setuptools and not from_pyximport and not from_cy_buildext:
warnings.warn(
"Cython.Distutils.old_build_ext does not properly handle dependencies "
"and is deprecated.")
try: try:
from __builtin__ import basestring from __builtin__ import basestring
except ImportError: except ImportError:
basestring = str basestring = str
def _check_stack(path):
try:
for frame in inspect.getouterframes(inspect.currentframe(), 0):
if path in frame[1].replace(os.sep, '/'):
return True
except Exception:
pass
return False
if (not _check_stack('setuptools/extensions.py')
and not _check_stack('pyximport/pyxbuild.py')
and not _check_stack('Cython/Distutils/build_ext.py')):
warnings.warn(
"Cython.Distutils.old_build_ext does not properly handle dependencies "
"and is deprecated.")
extension_name_re = _build_ext.extension_name_re extension_name_re = _build_ext.extension_name_re
show_compilers = _build_ext.show_compilers show_compilers = _build_ext.show_compilers
......
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