Skip to content

Can't find 64-bit GhostScript on win64 #2278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 18, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,21 @@ def checkdep_dvipng():
def checkdep_ghostscript():
try:
if sys.platform == 'win32':
command_args = ['gswin32c', '--version']
gs_execs = ['gswin32c', 'gswin64c', 'gs']
else:
command_args = ['gs', '--version']
s = subprocess.Popen(command_args, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
v = byte2str(s.stdout.read()[:-1])
return v
gs_execs = ['gs']
for gs_exec in gs_execs:
s = subprocess.Popen(
[gs_exec, '--version'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = s.communicate()
if s.returncode == 0:
v = byte2str(stdout[:-1])
return gs_exec, v

return None, None
except (IndexError, ValueError, OSError):
return None
return None, None

def checkdep_tex():
try:
Expand Down Expand Up @@ -397,7 +403,7 @@ def checkdep_ps_distiller(s):
flag = True
gs_req = '7.07'
gs_sugg = '7.07'
gs_v = checkdep_ghostscript()
gs_exec, gs_v = checkdep_ghostscript()
if compare_versions(gs_v, gs_sugg): pass
elif compare_versions(gs_v, gs_req):
verbose.report(('ghostscript-%s found. ghostscript-%s or later '
Expand Down Expand Up @@ -452,7 +458,7 @@ def checkdep_usetex(s):
'backend unless dvipng-1.5 or later is '
'installed on your system')

gs_v = checkdep_ghostscript()
gs_exec, gs_v = checkdep_ghostscript()
if compare_versions(gs_v, gs_sugg): pass
elif compare_versions(gs_v, gs_req):
verbose.report(('ghostscript-%s found. ghostscript-%s or later is '
Expand Down
8 changes: 2 additions & 6 deletions lib/matplotlib/testing/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,8 @@ def convert(old, new):

return convert

if matplotlib.checkdep_ghostscript() is not None:
if sys.platform == 'win32':
gs = 'gswin32c'
else:
gs = 'gs'

gs, gs_v = matplotlib.checkdep_ghostscript()
if gs_v is not None:
cmd = lambda old, new: \
[gs, '-q', '-sDEVICE=png16m', '-dNOPAUSE', '-dBATCH',
'-sOutputFile=' + new, old]
Expand Down
47 changes: 23 additions & 24 deletions setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,6 @@ def get_base_dirs():
return basedir_map.get(sys.platform, ['/usr/local', '/usr'])


def run_child_process(cmd):
"""
Run a subprocess as a sanity check.
"""
p = subprocess.Popen(cmd, shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
close_fds=(sys.platform != 'win32'))
return p.stdin, p.stdout


def is_min_version(found, minversion):
"""
Returns `True` if `found` is at least as high a version as
Expand Down Expand Up @@ -1713,9 +1701,10 @@ class DviPng(SetupPackage):

def check(self):
try:
stdin, stdout = run_child_process('dvipng -version')
return "version %s" % stdout.readlines()[1].decode().split()[-1]
except (IndexError, ValueError):
output = check_output('dvipng -version', shell=True,
stderr=subprocess.STDOUT)
return "version %s" % output.splitlines()[1].decode().split()[-1]
except (IndexError, ValueError, subprocess.CalledProcessError):
raise CheckFailed()


Expand All @@ -1727,11 +1716,19 @@ def check(self):
try:
if sys.platform == 'win32':
command = 'gswin32c --version'
try:
output = check_output(command, shell=True,
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError:
command = 'gswin64c --version'
output = check_output(command, shell=True,
stderr=subprocess.STDOUT)
else:
command = 'gs --version'
stdin, stdout = run_child_process(command)
return "version %s" % stdout.read().decode()[:-1]
except (IndexError, ValueError):
output = check_output(command, shell=True,
stderr=subprocess.STDOUT)
return "version %s" % output.decode()[:-1]
except (IndexError, ValueError, subprocess.CalledProcessError):
raise CheckFailed()


Expand All @@ -1741,12 +1738,13 @@ class LaTeX(SetupPackage):

def check(self):
try:
stdin, stdout = run_child_process('latex -version')
line = stdout.readlines()[0].decode()
output = check_output('latex -version', shell=True,
stderr=subprocess.STDOUT)
line = output.splitlines()[0].decode()
pattern = '(3\.1\d+)|(MiKTeX \d+.\d+)'
match = re.search(pattern, line)
return "version %s" % match.group(0)
except (IndexError, ValueError, AttributeError):
except (IndexError, ValueError, AttributeError, subprocess.CalledProcessError):
raise CheckFailed()


Expand All @@ -1756,12 +1754,13 @@ class PdfToPs(SetupPackage):

def check(self):
try:
stdin, stdout = run_child_process('pdftops -v')
for line in stdout.readlines():
output = check_output('pdftops -v', shell=True,
stderr=subprocess.STDOUT)
for line in output.splitlines():
line = line.decode()
if 'version' in line:
return "version %s" % line.split()[2]
except (IndexError, ValueError):
except (IndexError, ValueError, subprocess.CalledProcessError):
pass

raise CheckFailed()