PageRenderTime 70ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/fstmerge/examples/matplotlib/rev7315-8135/base-trunk-7315/setup.py

https://github.com/RoDaniel/featurehouse
Python | 201 lines | 194 code | 0 blank | 7 comment | 11 complexity | 947255e4a54b86199ee5513a10532528 MD5 | raw file
  1. """
  2. You will need to have freetype, libpng and zlib installed to comile
  3. matplotlib, inlcuding the *-devel versions of these libraries if you
  4. are using a package manager like RPM or debian.
  5. The matplotlib build options can be modified with a setup.cfg file. See
  6. setup.cfg.template for more information.
  7. """
  8. import os
  9. try:
  10. del os.link
  11. except AttributeError:
  12. pass
  13. rc = {'backend':'Agg'}
  14. import os
  15. if os.path.exists('MANIFEST'): os.remove('MANIFEST')
  16. import sys
  17. major, minor1, minor2, s, tmp = sys.version_info
  18. if major==2 and minor1<4 or major<2:
  19. raise SystemExit("""matplotlib requires Python 2.4 or later.""")
  20. import glob
  21. from distutils.core import setup
  22. from setupext import build_agg, build_gtkagg, build_tkagg, build_wxagg,\
  23. build_macosx, build_ft2font, build_image, build_windowing, build_path, \
  24. build_contour, build_delaunay, build_nxutils, build_gdk, \
  25. build_ttconv, print_line, print_status, print_message, \
  26. print_raw, check_for_freetype, check_for_libpng, check_for_gtk, \
  27. check_for_tk, check_for_wx, check_for_macosx, check_for_numpy, \
  28. check_for_qt, check_for_qt4, check_for_cairo, \
  29. check_provide_pytz, check_provide_dateutil,\
  30. check_for_dvipng, check_for_ghostscript, check_for_latex, \
  31. check_for_pdftops, check_for_datetime, options, build_png
  32. packages = [
  33. 'matplotlib',
  34. 'matplotlib.backends',
  35. 'matplotlib.projections',
  36. 'mpl_toolkits',
  37. 'mpl_toolkits.mplot3d',
  38. 'mpl_toolkits.axes_grid',
  39. 'matplotlib.sphinxext',
  40. 'matplotlib.numerix',
  41. 'matplotlib.numerix.mlab',
  42. 'matplotlib.numerix.ma',
  43. 'matplotlib.numerix.linear_algebra',
  44. 'matplotlib.numerix.random_array',
  45. 'matplotlib.numerix.fft',
  46. ]
  47. py_modules = ['pylab']
  48. ext_modules = []
  49. for line in file('lib/matplotlib/__init__.py').readlines():
  50. if (line.startswith('__version__')):
  51. exec(line.strip())
  52. print_line()
  53. print_raw("BUILDING MATPLOTLIB")
  54. print_status('matplotlib', __version__)
  55. print_status('python', sys.version)
  56. print_status('platform', sys.platform)
  57. if sys.platform == 'win32':
  58. print_status('Windows version', sys.getwindowsversion())
  59. print_raw("")
  60. print_raw("REQUIRED DEPENDENCIES")
  61. package_data = {'matplotlib':['mpl-data/fonts/afm/*.afm',
  62. 'mpl-data/fonts/pdfcorefonts/*.afm',
  63. 'mpl-data/fonts/pdfcorefonts/*.txt',
  64. 'mpl-data/fonts/ttf/*.ttf',
  65. 'mpl-data/images/*.xpm',
  66. 'mpl-data/images/*.svg',
  67. 'mpl-data/images/*.png',
  68. 'mpl-data/images/*.ppm',
  69. 'mpl-data/example/*.npy',
  70. 'mpl-data/matplotlibrc',
  71. 'mpl-data/matplotlib.conf',
  72. 'mpl-data/*.glade',
  73. 'backends/Matplotlib.nib/*',
  74. ]}
  75. if not check_for_numpy():
  76. sys.exit(1)
  77. if not check_for_freetype():
  78. sys.exit(1)
  79. build_ft2font(ext_modules, packages)
  80. build_ttconv(ext_modules, packages)
  81. build_contour(ext_modules, packages)
  82. build_delaunay(ext_modules, packages)
  83. build_nxutils(ext_modules, packages)
  84. build_path(ext_modules, packages)
  85. print_raw("")
  86. print_raw("OPTIONAL BACKEND DEPENDENCIES")
  87. has_libpng = check_for_libpng()
  88. if has_libpng and options['build_agg']:
  89. build_agg(ext_modules, packages)
  90. rc['backend'] = 'Agg'
  91. else:
  92. rc['backend'] = 'SVG'
  93. if has_libpng and options['build_image']:
  94. build_image(ext_modules, packages)
  95. if has_libpng and options['build_agg'] or options['build_image']:
  96. build_png(ext_modules, packages)
  97. if options['build_windowing'] and sys.platform=='win32':
  98. build_windowing(ext_modules, packages)
  99. if options['build_tkagg']:
  100. if check_for_tk() or (options['build_tkagg'] is True):
  101. options['build_agg'] = 1
  102. build_tkagg(ext_modules, packages)
  103. rc['backend'] = 'TkAgg'
  104. if options['build_wxagg']:
  105. if check_for_wx() or (options['build_wxagg'] is True):
  106. options['build_agg'] = 1
  107. import wx
  108. if getattr(wx, '__version__', '0.0')[0:3] < '2.8' :
  109. build_wxagg(ext_modules, packages)
  110. wxagg_backend_status = "yes"
  111. else:
  112. print_message("WxAgg extension not required for wxPython >= 2.8")
  113. rc['backend'] = 'WXAgg'
  114. hasgtk = check_for_gtk()
  115. if options['build_gtk']:
  116. if hasgtk or (options['build_gtk'] is True):
  117. build_gdk(ext_modules, packages)
  118. if options['build_gtkagg']:
  119. if hasgtk or (options['build_gtkagg'] is True):
  120. options['build_agg'] = 1
  121. build_gtkagg(ext_modules, packages)
  122. rc['backend'] = 'GTKAgg'
  123. if options['build_macosx']:
  124. if check_for_macosx() or (options['build_macosx'] is True):
  125. build_macosx(ext_modules, packages)
  126. rc['backend'] = 'MacOSX'
  127. check_for_qt()
  128. check_for_qt4()
  129. check_for_cairo()
  130. print_raw("")
  131. print_raw("OPTIONAL DATE/TIMEZONE DEPENDENCIES")
  132. hasdatetime = check_for_datetime()
  133. provide_dateutil = check_provide_dateutil(hasdatetime)
  134. provide_pytz = check_provide_pytz(hasdatetime)
  135. if hasdatetime: # dates require python23 datetime
  136. def add_pytz():
  137. packages.append('pytz')
  138. resources = ['zone.tab', 'locales/pytz.pot']
  139. for dirpath, dirnames, filenames in os.walk(os.path.join('lib', 'pytz', 'zoneinfo')):
  140. if '.svn' in dirpath: continue
  141. basepath = os.path.join(*dirpath.split(os.path.sep)[2:])
  142. resources.extend([os.path.join(basepath, filename)
  143. for filename in filenames])
  144. package_data['pytz'] = resources
  145. assert len(resources) > 10, 'zoneinfo files not found!'
  146. def add_dateutil():
  147. packages.append('dateutil')
  148. packages.append('dateutil/zoneinfo')
  149. package_data['dateutil'] = ['zoneinfo/zoneinfo*.tar.*']
  150. if sys.platform=='win32':
  151. add_pytz()
  152. add_dateutil()
  153. else:
  154. if provide_pytz:
  155. add_pytz()
  156. print 'adding pytz'
  157. if provide_dateutil: add_dateutil()
  158. print_raw("")
  159. print_raw("OPTIONAL USETEX DEPENDENCIES")
  160. check_for_dvipng()
  161. check_for_ghostscript()
  162. check_for_latex()
  163. check_for_pdftops()
  164. print_raw("")
  165. print_raw("[Edit setup.cfg to suppress the above messages]")
  166. print_line()
  167. if options['backend']: rc['backend'] = options['backend']
  168. template = file('matplotlibrc.template').read()
  169. file('lib/matplotlib/mpl-data/matplotlibrc', 'w').write(template%rc)
  170. template = file('lib/matplotlib/mpl-data/matplotlib.conf.template').read()
  171. template = template.replace("datapath = ", "#datapath = ")
  172. template = template.replace(" use = 'Agg'", " use = '%s'"%rc['backend'])
  173. file('lib/matplotlib/mpl-data/matplotlib.conf', 'w').write(template)
  174. try: additional_params # has setupegg.py provided
  175. except NameError: additional_params = {}
  176. for mod in ext_modules:
  177. if options['verbose']:
  178. mod.extra_compile_args.append('-DVERBOSE')
  179. print 'pymods', py_modules
  180. print 'packages', packages
  181. distrib = setup(name="matplotlib",
  182. version= __version__,
  183. description = "Python plotting package",
  184. author = "John D. Hunter",
  185. author_email="jdh2358@gmail.com",
  186. url = "http://matplotlib.sourceforge.net",
  187. long_description = """
  188. matplotlib strives to produce publication quality 2D graphics
  189. for interactive graphing, scientific publishing, user interface
  190. development and web application servers targeting multiple user
  191. interfaces and hardcopy output formats. There is a 'pylab' mode
  192. which emulates matlab graphics
  193. """,
  194. packages = packages,
  195. platforms='any',
  196. py_modules = py_modules,
  197. ext_modules = ext_modules,
  198. package_dir = {'': 'lib'},
  199. package_data = package_data,
  200. **additional_params
  201. )