Skip to content

Commit

Permalink
updated dependency report during build process
Browse files Browse the repository at this point in the history
svn path=/trunk/matplotlib/; revision=4183
  • Loading branch information
ddale committed Nov 9, 2007
1 parent cc4ed7c commit e910272
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 52 deletions.
2 changes: 1 addition & 1 deletion lib/matplotlib/__init__.py
Expand Up @@ -256,7 +256,7 @@ def checkdep_tex():
v = match.group(0)
float(v)
return v
except (IndexError, ValueError):
except (IndexError, ValueError, AttributeError):
return None

def checkdep_pdftops():
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/config/checkdep.py
Expand Up @@ -35,7 +35,7 @@ def tex():
pattern = '3\.1\d+'
match = re.search(pattern, line)
return match.group(0)
except (IndexError, ValueError):
except (IndexError, ValueError, AttributeError):
return None

def pdftops():
Expand Down
102 changes: 56 additions & 46 deletions setup.py
Expand Up @@ -83,7 +83,8 @@
print_raw, check_for_freetype, check_for_libpng, check_for_gtk, \
check_for_tk, check_for_wx, check_for_numpy, check_for_qt, check_for_qt4, \
check_for_cairo, check_for_traits, check_for_pytz, check_for_dateutil, \
check_for_configobj
check_for_configobj, check_for_dvipng, check_for_ghostscript, \
check_for_latex, check_for_pdftops, check_for_datetime
#import distutils.sysconfig

# jdh
Expand Down Expand Up @@ -184,54 +185,11 @@
build_contour(ext_modules, packages)
build_nxutils(ext_modules, packages)

print_raw("")
print_raw("OPTIONAL DEPENDENCIES")

try: import datetime
except ImportError: hasdatetime = False
else: hasdatetime = True

if hasdatetime: # dates require python23 datetime
# only install pytz and dateutil if the user hasn't got them
def add_pytz():
packages.append('pytz')
resources = ['zone.tab', 'locales/pytz.pot']
# install pytz subdirs
for dirpath, dirname, filenames in os.walk(os.path.join('lib', 'pytz',
'zoneinfo')):
if '.svn' not in dirpath:
# remove the 'lib/pytz' part of the path
basepath = dirpath.split(os.path.sep, 2)[2]
resources.extend([os.path.join(basepath, filename)
for filename in filenames])
package_data['pytz'] = resources
assert len(resources) > 10, 'pytz zoneinfo files not found!'
# packages.append('/'.join(dirpath.split(os.sep)[1:]))

def add_dateutil():
packages.append('dateutil')
packages.append('dateutil/zoneinfo')
package_data['dateutil'] = ['zoneinfo/zoneinfo*.tar.*']

haspytz = check_for_pytz()
hasdateutil = check_for_dateutil()

if sys.platform=='win32':
# always add these to the win32 installer
add_pytz()
add_dateutil()
else:
# only add them if we need them
if not haspytz: add_pytz()
if not hasdateutil: add_dateutil()

build_swigagg(ext_modules, packages)
build_transforms(ext_modules, packages)

# for the traited config package:
if not check_for_configobj(): py_modules.append('configobj')

if not check_for_traits(): build_traits(ext_modules, packages)
print_raw("")
print_raw("OPTIONAL BACKEND DEPENDENCIES")

if check_for_gtk() and (BUILD_GTK or BUILD_GTKAGG):
if BUILD_GTK:
Expand Down Expand Up @@ -278,6 +236,58 @@ def add_dateutil():
if VERBOSE:
mod.extra_compile_args.append('-DVERBOSE')

print_raw("")
print_raw("OPTIONAL DATE/TIMEZONE DEPENDENCIES")

hasdatetime = check_for_datetime()
hasdateutil = check_for_dateutil(hasdatetime)
haspytz = check_for_pytz(hasdatetime)

if hasdatetime: # dates require python23 datetime
# only install pytz and dateutil if the user hasn't got them

def add_pytz():
packages.append('pytz')
resources = ['zone.tab', 'locales/pytz.pot']
# install pytz subdirs
for dirpath, dirname, filenames in os.walk(os.path.join('lib', 'pytz',
'zoneinfo')):
if '.svn' not in dirpath:
# remove the 'lib/pytz' part of the path
basepath = dirpath.split(os.path.sep, 2)[2]
resources.extend([os.path.join(basepath, filename)
for filename in filenames])
package_data['pytz'] = resources
assert len(resources) > 10, 'pytz zoneinfo files not found!'
# packages.append('/'.join(dirpath.split(os.sep)[1:]))

def add_dateutil():
packages.append('dateutil')
packages.append('dateutil/zoneinfo')
package_data['dateutil'] = ['zoneinfo/zoneinfo*.tar.*']

if sys.platform=='win32':
# always add these to the win32 installer
add_pytz()
add_dateutil()
else:
# only add them if we need them
if not haspytz: add_pytz()
if not hasdateutil: add_dateutil()

print_raw("")
print_raw("OPTIONAL USETEX DEPENDENCIES")
check_for_dvipng()
check_for_ghostscript()
check_for_latex()
check_for_pdftops()

# TODO: comment out for mpl release:
print_raw("")
print_raw("EXPERIMENTAL CONFIG PACKAGE DEPENDENCIES")
if not check_for_configobj(): py_modules.append('configobj')
if not check_for_traits(): build_traits(ext_modules, packages)

print_raw("")
print_raw("[Edit setup.cfg to suppress the above messages]")
print_line()
Expand Down
66 changes: 62 additions & 4 deletions setupext.py
Expand Up @@ -42,6 +42,7 @@
"""

import os
import re


basedir = {
Expand Down Expand Up @@ -325,21 +326,33 @@ def check_for_cairo():
print_status("Cairo", cairo.version)
return True

def check_for_pytz():
def check_for_datetime():
try:
import datetime
except ImportError:
print_status("datetime", "no")
return False
else:
print_status("datetime", "present, version unknown")
return True

def check_for_pytz(hasdatetime=True):
try:
import pytz
except ImportError:
print_status("pytz", "mpl-provided")
if hasdatetime: print_status("pytz", "mpl-provided")
else: print_status("pytz", "no")
return False
else:
print_status("pytz", pytz.__version__)
return True

def check_for_dateutil():
def check_for_dateutil(hasdatetime=True):
try:
import dateutil
except ImportError:
print_status("dateutil", "mpl-provided")
if hasdatetime: print_status("dateutil", "mpl-provided")
else: print_status("dateutil", "no")
return False
else:
try:
Expand Down Expand Up @@ -375,6 +388,51 @@ def check_for_traits():
print_status("enthought.traits", "no")
return gotit

def check_for_dvipng():
try:
stdin, stdout = os.popen4('dvipng -version')
print_status("dvipng", stdout.readlines()[1].split()[-1])
return True
except (IndexError, ValueError):
print_status("dvipng", "no")
return False

def check_for_ghostscript():
try:
if sys.platform == 'win32':
command = 'gswin32c --version'
else:
command = 'gs --version'
stdin, stdout = os.popen4(command)
print_status("ghostscript", stdout.read()[:-1])
return True
except (IndexError, ValueError):
print_status("ghostscript", "no")
return False

def check_for_latex():
try:
stdin, stdout = os.popen4('latex -version')
line = stdout.readlines()[0]
pattern = '3\.1\d+'
match = re.search(pattern, line)
print_status("latex", match.group(0))
return True
except (IndexError, ValueError, AttributeError):
print_status("latex", "no")
return False

def check_for_pdftops():
try:
stdin, stdout = os.popen4('pdftops -v')
for line in stdout.readlines():
if 'version' in line:
print_status("pdftops", line.split()[-1])
return True
except (IndexError, ValueError):
print_status("pdftops", "no")
return False

def check_for_numpy():
gotit = False
try:
Expand Down

0 comments on commit e910272

Please sign in to comment.