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