Commit 02e24158 authored by Stefan Behnel's avatar Stefan Behnel

fix test runner and pyximport in Py 2.7.9 and 3.4+: setuptools replaces...

fix test runner and pyximport in Py 2.7.9 and 3.4+: setuptools replaces "distutils.dist.Distribution" *after* we import it, which then breaks the input validation in "distutils.cmd"
parent 1b2363da
......@@ -6,7 +6,6 @@ out_fname = pyx_to_dll("foo.pyx")
import os
import sys
from distutils.dist import Distribution
from distutils.errors import DistutilsArgError, DistutilsError, CCompilerError
from distutils.extension import Extension
from distutils.util import grok_environment_error
......@@ -67,9 +66,12 @@ def pyx_to_dll(filename, ext = None, force_rebuild = 0,
if HAS_CYTHON and build_in_temp:
args.append("--pyrex-c-in-temp")
sargs = setup_args.copy()
sargs.update(
{"script_name": None,
"script_args": args + script_args} )
sargs.update({
"script_name": None,
"script_args": args + script_args,
})
# late import, in case setuptools replaced it
from distutils.dist import Distribution
dist = Distribution(sargs)
if not dist.ext_modules:
dist.ext_modules = []
......
......@@ -71,14 +71,19 @@ except NameError:
WITH_CYTHON = True
CY3_DIR = None
from distutils.dist import Distribution
from distutils.core import Extension
from distutils.command.build_ext import build_ext as _build_ext
from distutils import sysconfig
distutils_distro = Distribution()
if sys.platform == 'win32':
def get_distutils_distro(_cache=[]):
if _cache:
return _cache[0]
# late import to accomodate for setuptools override
from distutils.dist import Distribution
distutils_distro = Distribution()
if sys.platform == 'win32':
# TODO: Figure out why this hackery (see http://thread.gmane.org/gmane.comp.python.cython.devel/8280/).
config_files = distutils_distro.find_config_files()
try: config_files.remove('setup.cfg')
......@@ -89,6 +94,9 @@ if sys.platform == 'win32':
try: cfgfiles.remove('setup.cfg')
except ValueError: pass
distutils_distro.parse_config_files(cfgfiles)
_cache.append(distutils_distro)
return distutils_distro
EXT_DEP_MODULES = {
'tag:numpy' : 'numpy',
......@@ -802,7 +810,7 @@ class CythonCompileTestCase(unittest.TestCase):
cwd = os.getcwd()
os.chdir(workdir)
try:
build_extension = build_ext(distutils_distro)
build_extension = build_ext(get_distutils_distro())
build_extension.include_dirs = INCLUDE_DIRS[:]
if incdir:
build_extension.include_dirs.append(incdir)
......
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