/tags/v0_7_1/toolkits/basemap/setup.py

https://github.com/ericliang/matplotlib · Python · 76 lines · 70 code · 3 blank · 3 comment · 2 complexity · 33624ad19f7b62fbea2056c68cfb8b9f MD5 · raw file

  1. from distutils.core import setup, Extension
  2. from distutils.util import convert_path
  3. import sys, glob
  4. def dbf_macros():
  5. """Return the macros to define when compiling the dbflib wrapper.
  6. The returned list specifies one macro, HAVE_UPDATE_HEADER, which is
  7. '1' if the dbflib version we will be compiling with has the
  8. DBFUpdateHeader function and '0' otherwise. To check whether
  9. DBFUpdateHeader is available, we scan shapefil.h for the string
  10. 'DBFUpdateHeader'.
  11. """
  12. f = open(convert_path("pyshapelib/shapelib/shapefil.h"))
  13. contents = f.read()
  14. f.close()
  15. if contents.find("DBFUpdateHeader") >= 0:
  16. return [("HAVE_UPDATE_HEADER", "1")]
  17. else:
  18. return [("HAVE_UPDATE_HEADER", "0")]
  19. deps = glob.glob('src/*.c')
  20. extensions = [Extension("proj4",deps,include_dirs = ['src'],)]
  21. packages = ['matplotlib/toolkits','matplotlib/toolkits/basemap']
  22. package_dirs = {'':'lib'}
  23. # don't build pyshapelib if it is already installed.
  24. try:
  25. import shapelib
  26. import dbflib
  27. except:
  28. packages = packages + ['shapelib','dbflib']
  29. package_dirs['shapelib'] ='pyshapelib/lib/shapelib'
  30. package_dirs['dbflib'] ='pyshapelib/lib/dbflib'
  31. extensions = extensions + \
  32. [Extension("shapelibc",
  33. ["pyshapelib/shapelib_wrap.c",
  34. "pyshapelib/shapelib/shpopen.c",
  35. "pyshapelib/shapelib/shptree.c"],
  36. include_dirs = ["pyshapelib/shapelib"]),
  37. Extension("shptree",
  38. ["pyshapelib/shptreemodule.c"],
  39. include_dirs = ["pyshapelib/shapelib"]),
  40. Extension("dbflibc",
  41. ["pyshapelib/dbflib_wrap.c",
  42. "pyshapelib/shapelib/dbfopen.c"],
  43. include_dirs = ["pyshapelib/shapelib"],
  44. define_macros = dbf_macros()) ]
  45. setup(
  46. name = "basemap",
  47. version = "0.7",
  48. description = "Plot data on map projections with matplotlib",
  49. long_description = """
  50. An add-on toolkit for matplotlib that lets you plot data
  51. on map projections with coastlines, lakes, rivers and political boundaries.
  52. See http://www.scipy.org/wikis/topical_software/Maps for an
  53. example of what it can do.""",
  54. url = "http://matplotlib.sourceforge.net/toolkits.html",
  55. download_url = "http://sourceforge.net/projects/matplotlib",
  56. author = "Jeff Whitaker",
  57. author_email = "jeffrey.s.whitaker@noaa.gov",
  58. platforms = ["any"],
  59. license = ["OSI Approved"],
  60. keywords = ["python","plotting","plots","graphs","charts","GIS","mapping","map projections","maps"],
  61. classifiers = ["Development Status :: 4 - Beta",
  62. "Intended Audience :: Science/Research",
  63. "License :: OSI Approved",
  64. "Topic :: Scientific/Engineering :: Visualization",
  65. "Topic :: Software Development :: Libraries :: Python Modules",
  66. "Operating System :: OS Independent"],
  67. packages = packages,
  68. package_dir = package_dirs,
  69. ext_modules = extensions)