PageRenderTime 28ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/v0_74/matplotlib/setup.py

https://github.com/ericliang/matplotlib
Python | 228 lines | 139 code | 48 blank | 41 comment | 42 complexity | 9a2537a99ceab2cf3fbf7b79a9143322 MD5 | raw file
  1. """
  2. Note! If you are building for python2.2, you must comment out the
  3. py_modules line below and manually copy lib/pylab.py to
  4. site-packages/pylab.py
  5. You will need to have freetype, libpng and zlib installed to compile
  6. matplotlib, inlcuding the *-devel versions of these libraries if you
  7. are using a package manager like RPM or debian.
  8. matplotlib has added some extension module code which can optionally
  9. be built by setting the appropriate flag below.
  10. The GTKAgg and TkAgg will try to build if they detect pygtk or Tkinter
  11. respectively; set them to 0 if you do not want to build them
  12. """
  13. # build the image support module - requires agg and Numeric or
  14. # numarray. You can build the image module with either Numeric or
  15. # numarray or both. By default, matplotlib will build support for
  16. # whatever array packages you have installed.
  17. BUILD_IMAGE = 1
  18. # Build the antigrain geometry toolkit. Agg makes heavy use of
  19. # templates, so it probably requires a fairly recent compiler to build
  20. # it. It makes very nice antialiased output and also supports alpha
  21. # blending
  22. BUILD_AGG = 1
  23. # Render Agg to the GTK canvas
  24. #BUILD_GTKAGG = 0
  25. BUILD_GTKAGG = 'auto'
  26. BUILD_GTK = 'auto'
  27. # build TK GUI with Agg renderer ; requires Tkinter Python extension
  28. # and Tk includes
  29. # Use False or 0 if you don't want to build
  30. #BUILD_TKAGG = 0
  31. BUILD_TKAGG = 'auto'
  32. # build a small extension to manage the focus on win32 platforms.
  33. #BUILD_WINDOWING = 0
  34. BUILD_WINDOWING = 'auto'
  35. VERBOSE = False # insert lots of diagnostic prints in extension code
  36. ## You shouldn't need to customize below this point
  37. from distutils.core import setup
  38. import sys,os
  39. import glob
  40. from distutils.core import Extension
  41. from setupext import build_agg, build_gtkagg, build_tkagg, \
  42. build_ft2font, build_image, build_windowing, build_transforms, \
  43. build_contour, build_enthought, build_swigagg, build_gdk
  44. import distutils.sysconfig
  45. major, minor1, minor2, s, tmp = sys.version_info
  46. if major==2 and minor1==2:
  47. print >> sys.stderr, "***\n\nWARNING, see build info for python2.2 in the header of setup.py\n\n***"
  48. for line in file('lib/matplotlib/__init__.py').readlines():
  49. if line[:11] == '__version__':
  50. exec(line)
  51. break
  52. data = []
  53. data.extend(glob.glob('fonts/afm/*.afm'))
  54. data.extend(glob.glob('fonts/ttf/*.ttf'))
  55. data.extend(glob.glob('images/*.xpm'))
  56. data.extend(glob.glob('images/*.svg'))
  57. data.extend(glob.glob('images/*.png'))
  58. data.extend(glob.glob('images/*.ppm'))
  59. data.append('.matplotlibrc')
  60. data_files=[('share/matplotlib', data),]
  61. # Figure out which array packages to provide binary support for
  62. # and define the NUMERIX value: Numeric, numarray, or both.
  63. try:
  64. import Numeric
  65. HAVE_NUMERIC=1
  66. except ImportError:
  67. HAVE_NUMERIC=0
  68. try:
  69. import numarray
  70. HAVE_NUMARRAY=1
  71. except ImportError:
  72. HAVE_NUMARRAY=0
  73. NUMERIX=["neither", "Numeric","numarray","both"][HAVE_NUMARRAY*2+HAVE_NUMERIC]
  74. if NUMERIX == "neither":
  75. raise RuntimeError("You must install Numeric, numarray, or both to build matplotlib")
  76. # This print interers with --version, which license depends on
  77. #print "Compiling matplotlib for:", NUMERIX
  78. ext_modules = []
  79. # these are not optional
  80. BUILD_FT2FONT = 1
  81. BUILD_CONTOUR = 1
  82. packages = [
  83. 'matplotlib',
  84. 'matplotlib/backends',
  85. 'matplotlib/numerix',
  86. 'matplotlib/numerix/mlab',
  87. 'matplotlib/numerix/ma',
  88. 'matplotlib/numerix/linear_algebra',
  89. 'matplotlib/numerix/random_array',
  90. 'matplotlib/numerix/fft',
  91. ]
  92. try: import datetime
  93. except ImportError: havedate = False
  94. else: havedate = True
  95. if havedate: # dates require python23 datetime
  96. # only install pytz and dateutil if the user hasn't got them
  97. def add_pytz():
  98. packages.append('pytz')
  99. # install pytz subdirs
  100. for dirpath, dirname, filenames in os.walk(os.path.join('lib', 'pytz','zoneinfo')):
  101. packages.append('/'.join(dirpath.split(os.sep)[1:]))
  102. def add_dateutil():
  103. packages.append('dateutil')
  104. if sys.platform=='win32':
  105. # always add these to the win32 installer
  106. add_pytz()
  107. add_dateutil()
  108. else:
  109. # only add them if we need them
  110. try: import dateutil
  111. except ImportError:
  112. add_dateutil()
  113. try: import pytz
  114. except ImportError:
  115. add_pytz()
  116. build_swigagg(ext_modules, packages)
  117. build_transforms(ext_modules, packages, NUMERIX)
  118. build_enthought(ext_modules, packages)
  119. if BUILD_GTK:
  120. try:
  121. import gtk
  122. except ImportError:
  123. print 'GTK requires pygtk'
  124. BUILD_GTK=0
  125. except RuntimeError:
  126. print 'pygtk present but import failed'
  127. if BUILD_GTK:
  128. build_gdk(ext_modules, packages, NUMERIX)
  129. if BUILD_GTKAGG:
  130. try:
  131. import gtk
  132. except ImportError:
  133. print 'GTKAgg requires pygtk'
  134. BUILD_GTKAGG=0
  135. except RuntimeError:
  136. print 'pygtk present but import failed'
  137. if BUILD_GTKAGG:
  138. BUILD_AGG = 1
  139. build_gtkagg(ext_modules, packages, NUMERIX)
  140. if BUILD_TKAGG:
  141. try: import Tkinter
  142. except ImportError: print 'TKAgg requires TkInter'
  143. else:
  144. BUILD_AGG = 1
  145. build_tkagg(ext_modules, packages, NUMERIX)
  146. if BUILD_AGG:
  147. build_agg(ext_modules, packages, NUMERIX)
  148. if BUILD_FT2FONT:
  149. build_ft2font(ext_modules, packages)
  150. if BUILD_WINDOWING and sys.platform=='win32':
  151. build_windowing(ext_modules, packages)
  152. if BUILD_IMAGE:
  153. build_image(ext_modules, packages, NUMERIX)
  154. if 1: # I don't think we need to make these optional
  155. build_contour(ext_modules, packages, NUMERIX)
  156. for mod in ext_modules:
  157. if VERBOSE:
  158. mod.extra_compile_args.append('-DVERBOSE')
  159. setup(name="matplotlib",
  160. version= __version__,
  161. description = "Matlab(TM) style python plotting package",
  162. author = "John D. Hunter",
  163. author_email="jdhunter@ace.bsd.uchicago.edu",
  164. url = "http://matplotlib.sourceforge.net",
  165. long_description = """
  166. matplotlib strives to produce publication quality 2D graphics
  167. using matlab plotting for inspiration. Although the main lib is
  168. object oriented, there is a functional interface "pylab"
  169. for people coming from Matlab.
  170. """,
  171. packages = packages,
  172. platforms='any',
  173. py_modules = ['pylab'],
  174. ext_modules = ext_modules,
  175. data_files = data_files,
  176. package_dir = {'': 'lib'},
  177. )