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

Skip to content

Commit 67abb8a

Browse files
committed
added flags in setup.cfg to disable providing external
packages like pytz and datetime svn path=/trunk/matplotlib/; revision=4214
1 parent db8d00f commit 67abb8a

3 files changed

Lines changed: 89 additions & 39 deletions

File tree

setup.cfg

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,18 @@ tag_svn_revision = 1
44
[status]
55
# To suppress display of the dependencies and their versions
66
# at the top of the build log, uncomment the following line:
7-
# suppress = 1
7+
#
8+
#suppress = True
9+
10+
[provide packages]
11+
# by default, matplotlib checks for a few dependencies and
12+
# installs them if missing. This feature can be turned off
13+
# by uncommenting the following lines:
14+
#
15+
## date/timezone support:
16+
#pytz = False
17+
#dateutil = False
18+
#
19+
## experimental config package support:
20+
#enthought.traits = False
21+
#configobj = False

setup.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313

1414
rc = {'backend':'PS', 'numerix':'numpy'}
1515

16-
# build the image support module - requires agg and Numeric or
17-
# numarray. You can build the image module with either Numeric or
18-
# numarray or both. By default, matplotlib will build support for
19-
# whatever array packages you have installed.
16+
# build the image support module - requires agg. By default, matplotlib will
17+
# build support for whatever array packages you have installed.
2018
BUILD_IMAGE = 1
2119

2220
# Build the antigrain geometry toolkit. Agg makes heavy use of
@@ -82,9 +80,10 @@
8280
build_subprocess, build_ttconv, print_line, print_status, print_message, \
8381
print_raw, check_for_freetype, check_for_libpng, check_for_gtk, \
8482
check_for_tk, check_for_wx, check_for_numpy, check_for_qt, check_for_qt4, \
85-
check_for_cairo, check_for_traits, check_for_pytz, check_for_dateutil, \
86-
check_for_configobj, check_for_dvipng, check_for_ghostscript, \
87-
check_for_latex, check_for_pdftops, check_for_datetime
83+
check_for_cairo, check_provide_traits, check_provide_pytz, \
84+
check_provide_dateutil, check_provide_configobj, check_for_dvipng, \
85+
check_for_ghostscript, check_for_latex, check_for_pdftops, \
86+
check_for_datetime
8887
#import distutils.sysconfig
8988

9089
# jdh
@@ -240,8 +239,8 @@
240239
print_raw("OPTIONAL DATE/TIMEZONE DEPENDENCIES")
241240

242241
hasdatetime = check_for_datetime()
243-
hasdateutil = check_for_dateutil(hasdatetime)
244-
haspytz = check_for_pytz(hasdatetime)
242+
provide_dateutil = check_provide_dateutil(hasdatetime)
243+
provide_pytz = check_provide_pytz(hasdatetime)
245244

246245
if hasdatetime: # dates require python23 datetime
247246
# only install pytz and dateutil if the user hasn't got them
@@ -272,8 +271,8 @@ def add_dateutil():
272271
add_dateutil()
273272
else:
274273
# only add them if we need them
275-
if not haspytz: add_pytz()
276-
if not hasdateutil: add_dateutil()
274+
if provide_pytz: add_pytz()
275+
if provide_dateutil: add_dateutil()
277276

278277
print_raw("")
279278
print_raw("OPTIONAL USETEX DEPENDENCIES")
@@ -285,8 +284,10 @@ def add_dateutil():
285284
# TODO: comment out for mpl release:
286285
print_raw("")
287286
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)
287+
if check_provide_configobj():
288+
py_modules.append('configobj')
289+
if check_provide_traits():
290+
build_traits(ext_modules, packages)
290291

291292
print_raw("")
292293
print_raw("[Edit setup.cfg to suppress the above messages]")

setupext.py

Lines changed: 60 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,33 @@
9898
numpy_inc_dirs = []
9999

100100
# Based on the contents of setup.cfg, determine if the status block
101-
# should be displayed
101+
# should be displayed, if missing external packages should be provided
102102
display_status = True
103+
provide_pytz = True
104+
provide_dateutil = True
105+
provide_configobj = True
106+
provide_traits = True
103107
if os.path.exists("setup.cfg"):
104108
config = ConfigParser.SafeConfigParser()
105109
config.read("setup.cfg")
106110
try:
107-
if config.get("status", "suppress"):
108-
display_status = False
111+
display_status = not config.getboolean("status", "suppress")
112+
except:
113+
pass
114+
try:
115+
provide_pytz = config.getboolean("provide packages", "pytz")
116+
except:
117+
pass
118+
try:
119+
provide_dateutil = config.getboolean("provide packages", "dateutil")
120+
except:
121+
pass
122+
try:
123+
provide_configobj = config.getboolean("provide packages", "configobj")
124+
except:
125+
pass
126+
try:
127+
provide_traits = config.getboolean("provide packages", "enthought.traits")
109128
except:
110129
pass
111130

@@ -336,57 +355,73 @@ def check_for_datetime():
336355
print_status("datetime", "present, version unknown")
337356
return True
338357

339-
def check_for_pytz(hasdatetime=True):
358+
def check_provide_pytz(hasdatetime=True):
340359
try:
341360
import pytz
342361
except ImportError:
343-
if hasdatetime: print_status("pytz", "mpl-provided")
344-
else: print_status("pytz", "no")
345-
return False
362+
if hasdatetime and provide_pytz:
363+
print_status("pytz", "mpl-provided")
364+
return True
365+
else:
366+
print_status("pytz", "no")
367+
return False
346368
else:
347369
print_status("pytz", pytz.__version__)
348-
return True
370+
return False
349371

350-
def check_for_dateutil(hasdatetime=True):
372+
def check_provide_dateutil(hasdatetime=True):
351373
try:
352374
import dateutil
353375
except ImportError:
354-
if hasdatetime: print_status("dateutil", "mpl-provided")
355-
else: print_status("dateutil", "no")
356-
return False
376+
if hasdatetime and provide_dateutil:
377+
print_status("dateutil", "mpl-provided")
378+
return True
379+
else:
380+
print_status("dateutil", "no")
381+
return False
357382
else:
358383
try:
359384
print_status("dateutil", dateutil.__version__)
360385
except AttributeError:
361386
print_status("dateutil", "present, version unknown")
362-
return True
387+
return False
363388

364-
def check_for_configobj():
389+
def check_provide_configobj():
365390
try:
366391
import configobj
367392
except ImportError:
368-
print_status("configobj", "mpl-provided")
369-
return False
393+
if provide_configobj:
394+
print_status("configobj", "mpl-provided")
395+
return True
396+
else:
397+
print_status("configobj", "no")
398+
return False
370399
else:
371400
print_status("configobj", configobj.__version__)
372-
return True
401+
return False
373402

374-
def check_for_traits():
375-
gotit = False
403+
def check_provide_traits():
376404
try:
377405
from enthought import traits
378-
gotit = True
379406
try:
380407
from enthought.traits import version
381408
except:
382409
print_status("enthought.traits", "unknown and incompatible version: < 2.0")
383-
return gotit
410+
return False
384411
else:
385-
if version.version.endswith('mpl'): gotit = False
386-
print_status("enthought.traits", version.version)
412+
if version.version.endswith('mpl'):
413+
print_status("enthought.traits", "mpl-provided")
414+
return True
415+
else:
416+
print_status("enthought.traits", version.version)
417+
return False
387418
except ImportError:
388-
print_status("enthought.traits", "no")
389-
return gotit
419+
if provide_traits:
420+
print_status("enthought.traits", "mpl-provided")
421+
return True
422+
else:
423+
print_status("enthought.traits", "no")
424+
return False
390425

391426
def check_for_dvipng():
392427
try:

0 commit comments

Comments
 (0)