Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e910272

Browse files
committed
updated dependency report during build process
svn path=/trunk/matplotlib/; revision=4183
1 parent cc4ed7c commit e910272

4 files changed

Lines changed: 120 additions & 52 deletions

File tree

lib/matplotlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def checkdep_tex():
256256
v = match.group(0)
257257
float(v)
258258
return v
259-
except (IndexError, ValueError):
259+
except (IndexError, ValueError, AttributeError):
260260
return None
261261

262262
def checkdep_pdftops():

lib/matplotlib/config/checkdep.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def tex():
3535
pattern = '3\.1\d+'
3636
match = re.search(pattern, line)
3737
return match.group(0)
38-
except (IndexError, ValueError):
38+
except (IndexError, ValueError, AttributeError):
3939
return None
4040

4141
def pdftops():

setup.py

Lines changed: 56 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@
8383
print_raw, check_for_freetype, check_for_libpng, check_for_gtk, \
8484
check_for_tk, check_for_wx, check_for_numpy, check_for_qt, check_for_qt4, \
8585
check_for_cairo, check_for_traits, check_for_pytz, check_for_dateutil, \
86-
check_for_configobj
86+
check_for_configobj, check_for_dvipng, check_for_ghostscript, \
87+
check_for_latex, check_for_pdftops, check_for_datetime
8788
#import distutils.sysconfig
8889

8990
# jdh
@@ -184,54 +185,11 @@
184185
build_contour(ext_modules, packages)
185186
build_nxutils(ext_modules, packages)
186187

187-
print_raw("")
188-
print_raw("OPTIONAL DEPENDENCIES")
189-
190-
try: import datetime
191-
except ImportError: hasdatetime = False
192-
else: hasdatetime = True
193-
194-
if hasdatetime: # dates require python23 datetime
195-
# only install pytz and dateutil if the user hasn't got them
196-
def add_pytz():
197-
packages.append('pytz')
198-
resources = ['zone.tab', 'locales/pytz.pot']
199-
# install pytz subdirs
200-
for dirpath, dirname, filenames in os.walk(os.path.join('lib', 'pytz',
201-
'zoneinfo')):
202-
if '.svn' not in dirpath:
203-
# remove the 'lib/pytz' part of the path
204-
basepath = dirpath.split(os.path.sep, 2)[2]
205-
resources.extend([os.path.join(basepath, filename)
206-
for filename in filenames])
207-
package_data['pytz'] = resources
208-
assert len(resources) > 10, 'pytz zoneinfo files not found!'
209-
# packages.append('/'.join(dirpath.split(os.sep)[1:]))
210-
211-
def add_dateutil():
212-
packages.append('dateutil')
213-
packages.append('dateutil/zoneinfo')
214-
package_data['dateutil'] = ['zoneinfo/zoneinfo*.tar.*']
215-
216-
haspytz = check_for_pytz()
217-
hasdateutil = check_for_dateutil()
218-
219-
if sys.platform=='win32':
220-
# always add these to the win32 installer
221-
add_pytz()
222-
add_dateutil()
223-
else:
224-
# only add them if we need them
225-
if not haspytz: add_pytz()
226-
if not hasdateutil: add_dateutil()
227-
228188
build_swigagg(ext_modules, packages)
229189
build_transforms(ext_modules, packages)
230190

231-
# for the traited config package:
232-
if not check_for_configobj(): py_modules.append('configobj')
233-
234-
if not check_for_traits(): build_traits(ext_modules, packages)
191+
print_raw("")
192+
print_raw("OPTIONAL BACKEND DEPENDENCIES")
235193

236194
if check_for_gtk() and (BUILD_GTK or BUILD_GTKAGG):
237195
if BUILD_GTK:
@@ -278,6 +236,58 @@ def add_dateutil():
278236
if VERBOSE:
279237
mod.extra_compile_args.append('-DVERBOSE')
280238

239+
print_raw("")
240+
print_raw("OPTIONAL DATE/TIMEZONE DEPENDENCIES")
241+
242+
hasdatetime = check_for_datetime()
243+
hasdateutil = check_for_dateutil(hasdatetime)
244+
haspytz = check_for_pytz(hasdatetime)
245+
246+
if hasdatetime: # dates require python23 datetime
247+
# only install pytz and dateutil if the user hasn't got them
248+
249+
def add_pytz():
250+
packages.append('pytz')
251+
resources = ['zone.tab', 'locales/pytz.pot']
252+
# install pytz subdirs
253+
for dirpath, dirname, filenames in os.walk(os.path.join('lib', 'pytz',
254+
'zoneinfo')):
255+
if '.svn' not in dirpath:
256+
# remove the 'lib/pytz' part of the path
257+
basepath = dirpath.split(os.path.sep, 2)[2]
258+
resources.extend([os.path.join(basepath, filename)
259+
for filename in filenames])
260+
package_data['pytz'] = resources
261+
assert len(resources) > 10, 'pytz zoneinfo files not found!'
262+
# packages.append('/'.join(dirpath.split(os.sep)[1:]))
263+
264+
def add_dateutil():
265+
packages.append('dateutil')
266+
packages.append('dateutil/zoneinfo')
267+
package_data['dateutil'] = ['zoneinfo/zoneinfo*.tar.*']
268+
269+
if sys.platform=='win32':
270+
# always add these to the win32 installer
271+
add_pytz()
272+
add_dateutil()
273+
else:
274+
# only add them if we need them
275+
if not haspytz: add_pytz()
276+
if not hasdateutil: add_dateutil()
277+
278+
print_raw("")
279+
print_raw("OPTIONAL USETEX DEPENDENCIES")
280+
check_for_dvipng()
281+
check_for_ghostscript()
282+
check_for_latex()
283+
check_for_pdftops()
284+
285+
# TODO: comment out for mpl release:
286+
print_raw("")
287+
print_raw("EXPERIMENTAL CONFIG PACKAGE DEPENDENCIES")
288+
if not check_for_configobj(): py_modules.append('configobj')
289+
if not check_for_traits(): build_traits(ext_modules, packages)
290+
281291
print_raw("")
282292
print_raw("[Edit setup.cfg to suppress the above messages]")
283293
print_line()

setupext.py

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"""
4343

4444
import os
45+
import re
4546

4647

4748
basedir = {
@@ -325,21 +326,33 @@ def check_for_cairo():
325326
print_status("Cairo", cairo.version)
326327
return True
327328

328-
def check_for_pytz():
329+
def check_for_datetime():
330+
try:
331+
import datetime
332+
except ImportError:
333+
print_status("datetime", "no")
334+
return False
335+
else:
336+
print_status("datetime", "present, version unknown")
337+
return True
338+
339+
def check_for_pytz(hasdatetime=True):
329340
try:
330341
import pytz
331342
except ImportError:
332-
print_status("pytz", "mpl-provided")
343+
if hasdatetime: print_status("pytz", "mpl-provided")
344+
else: print_status("pytz", "no")
333345
return False
334346
else:
335347
print_status("pytz", pytz.__version__)
336348
return True
337349

338-
def check_for_dateutil():
350+
def check_for_dateutil(hasdatetime=True):
339351
try:
340352
import dateutil
341353
except ImportError:
342-
print_status("dateutil", "mpl-provided")
354+
if hasdatetime: print_status("dateutil", "mpl-provided")
355+
else: print_status("dateutil", "no")
343356
return False
344357
else:
345358
try:
@@ -375,6 +388,51 @@ def check_for_traits():
375388
print_status("enthought.traits", "no")
376389
return gotit
377390

391+
def check_for_dvipng():
392+
try:
393+
stdin, stdout = os.popen4('dvipng -version')
394+
print_status("dvipng", stdout.readlines()[1].split()[-1])
395+
return True
396+
except (IndexError, ValueError):
397+
print_status("dvipng", "no")
398+
return False
399+
400+
def check_for_ghostscript():
401+
try:
402+
if sys.platform == 'win32':
403+
command = 'gswin32c --version'
404+
else:
405+
command = 'gs --version'
406+
stdin, stdout = os.popen4(command)
407+
print_status("ghostscript", stdout.read()[:-1])
408+
return True
409+
except (IndexError, ValueError):
410+
print_status("ghostscript", "no")
411+
return False
412+
413+
def check_for_latex():
414+
try:
415+
stdin, stdout = os.popen4('latex -version')
416+
line = stdout.readlines()[0]
417+
pattern = '3\.1\d+'
418+
match = re.search(pattern, line)
419+
print_status("latex", match.group(0))
420+
return True
421+
except (IndexError, ValueError, AttributeError):
422+
print_status("latex", "no")
423+
return False
424+
425+
def check_for_pdftops():
426+
try:
427+
stdin, stdout = os.popen4('pdftops -v')
428+
for line in stdout.readlines():
429+
if 'version' in line:
430+
print_status("pdftops", line.split()[-1])
431+
return True
432+
except (IndexError, ValueError):
433+
print_status("pdftops", "no")
434+
return False
435+
378436
def check_for_numpy():
379437
gotit = False
380438
try:

0 commit comments

Comments
 (0)