PageRenderTime 50ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/v0_6_1b/toolkits/basemap/setup.py

https://github.com/ericliang/matplotlib
Python | 64 lines | 57 code | 4 blank | 3 comment | 2 complexity | dcbfff8ddae4cf03ffe54dd65da9a618 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. datadir ='share/basemap-py'+repr(sys.version_info[0])+repr(sys.version_info[1])
  46. setup(
  47. name = "basemap",
  48. version = "0.6.1",
  49. description = "Plot data on map projections with matplotlib",
  50. url = "http://matplotlib.sourceforge.net/toolkits.html",
  51. author = "Jeff Whitaker",
  52. author_email = "jeffrey.s.whitaker@noaa.gov",
  53. data_files = [(datadir,['data/countries_c.txt','data/states_c.txt','data/countries_l.txt','data/states_l.txt','data/gshhs_c.txt','data/gshhs_l.txt','data/countries_i.txt','data/states_i.txt','data/gshhs_i.txt'])],
  54. packages = packages,
  55. package_dir = package_dirs,
  56. ext_modules = extensions)