|
98 | 98 | numpy_inc_dirs = [] |
99 | 99 |
|
100 | 100 | # 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 |
102 | 102 | display_status = True |
| 103 | +provide_pytz = True |
| 104 | +provide_dateutil = True |
| 105 | +provide_configobj = True |
| 106 | +provide_traits = True |
103 | 107 | if os.path.exists("setup.cfg"): |
104 | 108 | config = ConfigParser.SafeConfigParser() |
105 | 109 | config.read("setup.cfg") |
106 | 110 | 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") |
109 | 128 | except: |
110 | 129 | pass |
111 | 130 |
|
@@ -336,57 +355,73 @@ def check_for_datetime(): |
336 | 355 | print_status("datetime", "present, version unknown") |
337 | 356 | return True |
338 | 357 |
|
339 | | -def check_for_pytz(hasdatetime=True): |
| 358 | +def check_provide_pytz(hasdatetime=True): |
340 | 359 | try: |
341 | 360 | import pytz |
342 | 361 | 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 |
346 | 368 | else: |
347 | 369 | print_status("pytz", pytz.__version__) |
348 | | - return True |
| 370 | + return False |
349 | 371 |
|
350 | | -def check_for_dateutil(hasdatetime=True): |
| 372 | +def check_provide_dateutil(hasdatetime=True): |
351 | 373 | try: |
352 | 374 | import dateutil |
353 | 375 | 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 |
357 | 382 | else: |
358 | 383 | try: |
359 | 384 | print_status("dateutil", dateutil.__version__) |
360 | 385 | except AttributeError: |
361 | 386 | print_status("dateutil", "present, version unknown") |
362 | | - return True |
| 387 | + return False |
363 | 388 |
|
364 | | -def check_for_configobj(): |
| 389 | +def check_provide_configobj(): |
365 | 390 | try: |
366 | 391 | import configobj |
367 | 392 | 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 |
370 | 399 | else: |
371 | 400 | print_status("configobj", configobj.__version__) |
372 | | - return True |
| 401 | + return False |
373 | 402 |
|
374 | | -def check_for_traits(): |
375 | | - gotit = False |
| 403 | +def check_provide_traits(): |
376 | 404 | try: |
377 | 405 | from enthought import traits |
378 | | - gotit = True |
379 | 406 | try: |
380 | 407 | from enthought.traits import version |
381 | 408 | except: |
382 | 409 | print_status("enthought.traits", "unknown and incompatible version: < 2.0") |
383 | | - return gotit |
| 410 | + return False |
384 | 411 | 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 |
387 | 418 | 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 |
390 | 425 |
|
391 | 426 | def check_for_dvipng(): |
392 | 427 | try: |
|
0 commit comments