From: <ds...@us...> - 2008-12-02 17:12:17
|
Revision: 6471 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6471&view=rev Author: dsdale Date: 2008-12-02 17:11:07 +0000 (Tue, 02 Dec 2008) Log Message: ----------- improved checks for external dependencies Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/__init__.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-12-02 17:07:57 UTC (rev 6470) +++ trunk/matplotlib/CHANGELOG 2008-12-02 17:11:07 UTC (rev 6471) @@ -1,3 +1,7 @@ +2008-12-02 Improve checks for external dependencies, using subprocess + (instead of deprecated popen*) and distutils (for version + checking) - DSD + 2008-11-30 Reimplementaion of the legend which supports baseline alignement, multi-column, and expand mode. - JJL Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2008-12-02 17:07:57 UTC (rev 6470) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2008-12-02 17:11:07 UTC (rev 6471) @@ -93,8 +93,9 @@ __revision__ = '$Revision$' __date__ = '$Date$' -import os, re, shutil, sys, warnings +import os, re, shutil, subprocess, sys, warnings import distutils.sysconfig +import distutils.version NEWCONFIG = False @@ -256,10 +257,10 @@ def checkdep_dvipng(): try: - stdin, stdout = os.popen4('dvipng -version') - line = stdout.readlines()[1] + s = subprocess.Popen(['dvipng','-version'], stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + line = s.stdout.readlines()[1] v = line.split()[-1] - float(v) return v except (IndexError, ValueError): return None @@ -267,47 +268,45 @@ def checkdep_ghostscript(): try: if sys.platform == 'win32': - command = 'gswin32c --version' + command_args = ['gswin32c', '--version'] else: - command = 'gs --version' - stdin, stdout = os.popen4(command) - v = stdout.read()[:-1] - vtest = '.'.join(v.split('.')[:2]) # deal with version numbers like '7.07.1' - float(vtest) - return vtest + command_args = ['gs', '--version'] + s = subprocess.Popen(command_args, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + v = s.stdout.read()[:-1] + return v except (IndexError, ValueError): return None def checkdep_tex(): try: - stdin, stdout = os.popen4('tex -version') - line = stdout.readlines()[0] + s = subprocess.Popen(['tex','-version'], stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + line = s.stdout.readlines()[0] pattern = '3\.1\d+' match = re.search(pattern, line) v = match.group(0) - float(v) return v except (IndexError, ValueError, AttributeError): return None def checkdep_pdftops(): try: - stdin, stdout = os.popen4('pdftops -v') - for line in stdout.readlines(): + s = subprocess.Popen(['pdftops','-v'], stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + for line in s.stderr: if 'version' in line: v = line.split()[-1] - float(v) return v except (IndexError, ValueError, UnboundLocalError): return None def compare_versions(a, b): - "return True if a is greater than b" + "return True if a is greater than or equal to b" if a: - a = [int(i) for i in a.split('.')] - b = [int(i) for i in b.split('.')] - if a[0]>b[0]: return True - elif (a[0]==b[0]) and (a[1]>=b[1]): return True + a = distutils.version.LooseVersion(a) + b = distutils.version.LooseVersion(b) + if a>=b: return True else: return False else: return False @@ -330,8 +329,13 @@ if s == 'xpdf': pdftops_req = '3.0' + pdftops_req_alt = '0.9' # poppler version numbers, ugh pdftops_v = checkdep_pdftops() - if compare_versions(pdftops_v, pdftops_req): pass + if compare_versions(pdftops_v, pdftops_req): + pass + elif compare_versions(pdftops_v, pdftops_req_alt) and not \ + compare_versions(pdftops_v, '1.0'): + pass else: flag = False warnings.warn(('matplotlibrc ps.usedistiller can not be set to ' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |