Files

204 lines
7.6 KiB
Diff
Raw Permalink Normal View History

--- matplotlib-2.0.0/setupext.py.orig 2017-02-15 14:30:26 +0900
+++ matplotlib-2.0.0/setupext.py 2017-02-15 14:30:37 +0900
@@ -21,6 +21,8 @@
2016-09-24 13:13:12 +03:00
PY3min = (sys.version_info[0] >= 3)
2014-09-19 14:23:38 +04:00
+MSYS = "MSYSTEM" in os.environ
+
2014-09-19 14:23:38 +04:00
def _get_home():
"""Find user's home directory if possible.
@@ -68,9 +70,17 @@
# md5 hash of the freetype tarball
LOCAL_FREETYPE_HASH = '348e667d728c597360e4a87c16556597'
2014-09-19 14:23:38 +04:00
-if sys.platform != 'win32':
+if sys.platform != 'win32' or MSYS:
2016-09-24 13:13:12 +03:00
if not PY3min:
from commands import getstatusoutput
2014-09-19 14:23:38 +04:00
+ def getstatusoutput(cmd):
+ """Return (status, output) of executing cmd in a shell."""
+ pipe = os.popen(cmd, 'r')
+ text = pipe.read()
+ sts = pipe.close()
+ if sts is None: sts = 0
+ if text[-1:] == '\n': text = text[:-1]
+ return sts, text
else:
from subprocess import getstatusoutput
@@ -148,9 +158,10 @@
2014-10-19 17:30:49 +04:00
Returns `True` if `filename` can be found in one of the
2014-09-19 14:23:38 +04:00
directories in `include_dirs`.
"""
2014-10-19 17:30:49 +04:00
- if sys.platform == 'win32':
+ if sys.platform == 'win32' and not MSYS:
include_dirs += os.environ.get('INCLUDE', '.').split(';')
2014-09-19 14:23:38 +04:00
for dir in include_dirs:
+ dir = os.popen(' '.join(['cygpath', '-w', dir])).readline().strip()
if os.path.exists(os.path.join(dir, filename)):
return True
return False
@@ -261,6 +272,7 @@
2014-09-19 14:23:38 +04:00
"""
ext = DelayedExtension(name, files, *args, **kwargs)
for dir in get_base_dirs():
+ dir = os.popen(' '.join(['cygpath', '-w', dir])).readline().strip()
include_dir = os.path.join(dir, 'include')
if os.path.exists(include_dir):
ext.include_dirs.append(include_dir)
@@ -296,7 +308,7 @@
2014-09-19 14:23:38 +04:00
"""
Determines whether pkg-config exists on this machine.
"""
- if sys.platform == 'win32':
+ if sys.platform == 'win32' and not MSYS:
self.has_pkgconfig = False
else:
try:
@@ -305,7 +317,7 @@
self.pkg_config = 'pkg-config'
2014-09-19 14:23:38 +04:00
self.set_pkgconfig_path()
- status, output = getstatusoutput(self.pkg_config + " --help")
+ status, output = getstatusoutput('sh -c "' + self.pkg_config + ' --help"')
2014-09-19 14:23:38 +04:00
self.has_pkgconfig = (status == 0)
2014-10-19 17:30:49 +04:00
if not self.has_pkgconfig:
print("IMPORTANT WARNING:")
@@ -346,7 +358,7 @@
2014-09-19 14:23:38 +04:00
command = "{0} --libs --cflags ".format(executable)
try:
- output = check_output(command, shell=True,
+ output = check_output('sh -c "%s"' % command, shell=True,
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError:
pass
@@ -356,11 +368,16 @@
2014-09-19 14:23:38 +04:00
for token in output.split():
attr = flag_map.get(token[:2])
if attr is not None:
- getattr(ext, attr).insert(0, token[2:])
+ if attr.endswith('dirs'):
+ dir = os.popen(' '.join(['cygpath', '-w', token[2:]])).readline().strip()
+ getattr(ext, attr).insert(0, dir)
+ else:
+ getattr(ext, attr).insert(0, token[2:])
2014-09-19 14:23:38 +04:00
if use_defaults:
basedirs = get_base_dirs()
for base in basedirs:
+ base = os.popen(' '.join(['cygpath', '-w', base])).readline().strip()
for include in default_include_dirs:
dir = os.path.join(base, include)
if os.path.exists(dir):
@@ -382,7 +399,7 @@
2014-09-19 14:23:38 +04:00
return None
status, output = getstatusoutput(
- self.pkg_config + " %s --modversion" % (package))
+ 'sh -c "' + self.pkg_config + ' %s --modversion"' % (package))
2014-09-19 14:23:38 +04:00
if status == 0:
return output
return None
@@ -958,11 +975,11 @@
if options.get('local_freetype'):
return "Using local version for testing"
2014-09-19 14:23:38 +04:00
- if sys.platform == 'win32':
+ if sys.platform == 'win32' and not MSYS:
2014-10-19 17:30:49 +04:00
check_include_file(get_include_dirs(), 'ft2build.h', 'freetype')
return 'Using unknown version found on system.'
2014-09-19 14:23:38 +04:00
- status, output = getstatusoutput("freetype-config --ftversion")
+ status, output = getstatusoutput('sh -c "freetype-config --ftversion"')
if status == 0:
version = output
else:
@@ -987,6 +1004,8 @@
2014-09-19 14:23:38 +04:00
return version
# Return the first version found in the include dirs.
for include_dir in ext.include_dirs:
+ include_dir = os.popen(' '.join(['cygpath', '-w', include_dir])).readline().st
+ rip()
2014-09-19 14:23:38 +04:00
header_fname = os.path.join(include_dir, 'freetype.h')
if os.path.exists(header_fname):
major, minor, patch = 0, 0, 0
@@ -1136,11 +1155,11 @@
2014-10-19 17:30:49 +04:00
name = "png"
def check(self):
- if sys.platform == 'win32':
+ if sys.platform == 'win32' and not MSYS:
check_include_file(get_include_dirs(), 'png.h', 'png')
return 'Using unknown version found on system.'
- status, output = getstatusoutput("libpng-config --version")
+ status, output = getstatusoutput('sh -c "libpng-config --version"')
if status == 0:
version = output
else:
@@ -1602,7 +1621,7 @@
2014-09-19 14:23:38 +04:00
return ext
def add_flags(self, ext):
- if sys.platform == 'win32':
+ if sys.platform == 'win32' and not MSYS:
def getoutput(s):
ret = os.popen(s).read().strip()
return ret
@@ -1657,7 +1676,7 @@
2014-09-19 14:23:38 +04:00
'm' in ext.libraries):
ext.libraries.remove('m')
- elif sys.platform != 'win32':
+ elif sys.platform != 'win32' or MSYS:
pkg_config.setup_extension(ext, 'pygtk-2.0')
pkg_config.setup_extension(ext, 'gtk+-2.0')
@@ -2060,7 +2079,7 @@
2014-09-19 14:23:38 +04:00
def check(self):
try:
- output = check_output('dvipng -version', shell=True,
+ output = check_output('sh -c "dvipng -version"', shell=True,
stderr=subprocess.STDOUT)
return "version %s" % output.splitlines()[1].decode().split()[-1]
except (IndexError, ValueError, subprocess.CalledProcessError):
@@ -2072,14 +2091,14 @@
optional = True
2014-09-19 14:23:38 +04:00
def check(self):
- if sys.platform == 'win32':
+ if sys.platform == 'win32' and not MSYS:
# mgs is the name in miktex
gs_execs = ['gswin32c', 'gswin64c', 'mgs', 'gs']
else:
gs_execs = ['gs']
for gs_exec in gs_execs:
try:
- command = gs_exec + ' --version'
+ command = 'sh -c "%s --version"' % gs_exec
2014-09-19 14:23:38 +04:00
output = check_output(command, shell=True,
stderr=subprocess.STDOUT)
return "version %s" % output.decode()[:-1]
@@ -2095,7 +2114,7 @@
2014-09-19 14:23:38 +04:00
def check(self):
try:
- output = check_output('latex -version', shell=True,
+ output = check_output('sh -c "latex -version"', shell=True,
stderr=subprocess.STDOUT)
line = output.splitlines()[0].decode()
pattern = '(3\.1\d+)|(MiKTeX \d+.\d+)'
@@ -2111,7 +2130,7 @@
2014-09-19 14:23:38 +04:00
def check(self):
try:
- output = check_output('pdftops -v', shell=True,
+ output = check_output('sh -c "pdftops -v"', shell=True,
stderr=subprocess.STDOUT)
for line in output.splitlines():
line = line.decode()