summaryrefslogtreecommitdiff
path: root/setuptools/extension.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2016-09-27 14:24:22 -0500
committerJason R. Coombs <jaraco@jaraco.com>2016-09-27 14:24:22 -0500
commit66a6724da8eda3336643dee086da2a3495e6422a (patch)
tree64043e9782491bde3a3a9ae2314cc59451a6c9c0 /setuptools/extension.py
parentdf3905616933c90af95e99f705b800a2f5c1c921 (diff)
parent35ea365b50bd1a64375fdbcce187affab22af3b7 (diff)
downloadpython-setuptools-git-setuptools-scm.tar.gz
Merge with mastersetuptools-scm
Diffstat (limited to 'setuptools/extension.py')
-rw-r--r--setuptools/extension.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/setuptools/extension.py b/setuptools/extension.py
index d10609b6..03068d35 100644
--- a/setuptools/extension.py
+++ b/setuptools/extension.py
@@ -1,4 +1,3 @@
-import sys
import re
import functools
import distutils.core
@@ -7,18 +6,14 @@ import distutils.extension
from setuptools.extern.six.moves import map
-from .dist import _get_unpatched
-from . import msvc9_support
+from .monkey import get_unpatched
-_Extension = _get_unpatched(distutils.core.Extension)
-
-msvc9_support.patch_for_specialized_compiler()
def _have_cython():
"""
Return True if Cython can be imported.
"""
- cython_impl = 'Cython.Distutils.build_ext',
+ cython_impl = 'Cython.Distutils.build_ext'
try:
# from (cython_impl) import build_ext
__import__(cython_impl, fromlist=['build_ext']).build_ext
@@ -27,13 +22,23 @@ def _have_cython():
pass
return False
+
# for compatibility
have_pyrex = _have_cython
+_Extension = get_unpatched(distutils.core.Extension)
+
+
class Extension(_Extension):
"""Extension that uses '.c' files in place of '.pyx' files"""
+ def __init__(self, name, sources, *args, **kw):
+ # The *args is needed for compatibility as calls may use positional
+ # arguments. py_limited_api may be set only via keyword.
+ self.py_limited_api = kw.pop("py_limited_api", False)
+ _Extension.__init__(self, name, sources, *args, **kw)
+
def _convert_pyx_sources_to_lang(self):
"""
Replace sources with .pyx extensions to sources with the target
@@ -48,10 +53,6 @@ class Extension(_Extension):
sub = functools.partial(re.sub, '.pyx$', target_ext)
self.sources = list(map(sub, self.sources))
+
class Library(Extension):
"""Just like a regular Extension, but built as a library instead"""
-
-distutils.core.Extension = Extension
-distutils.extension.Extension = Extension
-if 'distutils.command.build_ext' in sys.modules:
- sys.modules['distutils.command.build_ext'].Extension = Extension