/[thuban]/branches/WIP-pyshapelib-bramz/libraries/pyshapelib/setup.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/libraries/pyshapelib/setup.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/thuban/libraries/pyshapelib/setup.py revision 2212 by bh, Mon May 17 15:47:57 2004 UTC branches/WIP-pyshapelib-bramz/libraries/pyshapelib/setup.py revision 2752 by bramz, Tue Apr 10 23:45:00 2007 UTC
# Line 1  Line 1 
1    
2  import os  import os
3    import sys
4  from distutils.core import setup, Extension  from distutils.core import setup, Extension
5  from distutils.util import convert_path  from distutils.util import convert_path
6    
# Line 11  from distutils.util import convert_path Line 12  from distutils.util import convert_path
12  # 2. Built in the Thuban source tree where ../shapelib/ relative to the  # 2. Built in the Thuban source tree where ../shapelib/ relative to the
13  #    directory containing this setup.py contains (the relevant parts of)  #    directory containing this setup.py contains (the relevant parts of)
14  #    shapelib  #    shapelib
15    #
16    # 3. Binary build with e.g. bdist_rpm.  This takes place deep in the
17    #    build directory.
18    
19  # os.path expects filenames in OS-specific form so we have to construct  # os.path expects filenames in OS-specific form so we have to construct
20  # the files with os.path functions. distutils, OTOH, uses posix-style  # the files with os.path functions. distutils, OTOH, uses posix-style
21  # filenames exclusively, so we use posix conventions when making  # filenames exclusively, so we use posix conventions when making
22  # filenames for distutils.  # filenames for distutils.
23  for shp_dir in ["..", "../shapelib"]:  for shp_dir in ["..", "../shapelib", "../../../../../../shapelib"]:
24      if os.path.exists(os.path.join(convert_path(shp_dir), "shpopen.c")):          if (os.path.isdir(convert_path(shp_dir))
25          # shp_dir contains shpopen.c, so assume it's the directory with                  and os.path.exists(os.path.join(convert_path(shp_dir), "shpopen.c"))):
26          # the shapefile library to use                  # shp_dir contains shpopen.c, so assume it's the directory with
27          break                  # the shapefile library to use
28                    break
29    else:
30            print >>sys.stderr, "no shapelib directory found"
31            sys.exit(1)
32    
33  def dbf_macros():  def dbf_macros():
34      """Return the macros to define when compiling the dbflib wrapper.          """Return the macros to define when compiling the dbflib wrapper.
35    
36      The returned list specifies one macro, HAVE_UPDATE_HEADER, which is          The returned list specifies following macros:
37      '1' if the dbflib version we will be compiling with has the          - HAVE_UPDATE_HEADER, which is
38      DBFUpdateHeader function and '0' otherwise.  To check whether          '1' if the dbflib version we will be compiling with has the
39      DBFUpdateHeader is available, we scan shapefil.h for the string          DBFUpdateHeader function and '0' otherwise.  To check whether
40      'DBFUpdateHeader'.          DBFUpdateHeader is available, we scan shapefil.h for the string
41      """          'DBFUpdateHeader'.
42      f = open(convert_path(shp_dir + "/shapefil.h"))          - HAVE_LANGUAGE_DRIVER, whics is '1' if the dbflib version we will
43      contents = f.read()          compiling with has the nLanguageDriver field in DBFInfo and '0' otherwise.
44      f.close()          Again, shapefil.h is scanned to check this.
45      print contents.find("DBFUpdateHeader")          """
46      if contents.find("DBFUpdateHeader") >= 0:          f = open(convert_path(shp_dir + "/shapefil.h"))
47          return [("HAVE_UPDATE_HEADER", "1")]          contents = f.read()
48      else:          f.close()
49          return [("HAVE_UPDATE_HEADER", "0")]          
50            def have(keyword):
51  extensions = [Extension("shapelibc",                  if keyword in contents:
52                          ["shapelib_wrap.c",                          return "1"
53                           shp_dir + "/shpopen.c",                  return 0
54                           shp_dir + "/shptree.c"],          
55                          include_dirs = [shp_dir]),          return [
56                Extension("shptree",                  ("HAVE_UPDATE_HEADER", have("DBFUpdateHeader")),
57                          ["shptreemodule.c"],                  ("HAVE_LANGUAGE_DRIVER", have("nLanguageDriver"))]
58                          include_dirs = [shp_dir]),  
59                Extension("dbflibc",  extensions = [Extension("shapelib",
60                          ["dbflib_wrap.c",                                                  ["shapelibmodule.c",
61                           shp_dir + "/dbfopen.c"],                                                  shp_dir + "/shpopen.c",
62                          include_dirs = [shp_dir],                                                  shp_dir + "/shptree.c"],
63                          define_macros = dbf_macros())]                                                  include_dirs = [shp_dir]),
64                            Extension("shptree",
65                                                    ["shptreemodule.c"],
66                                                    include_dirs = [shp_dir]),
67                            Extension("dbflib",
68                                                    ["dbflibmodule.c",
69                                                    shp_dir + "/dbfopen.c"],
70                                                    include_dirs = [shp_dir],
71                                                    define_macros = dbf_macros())]
72    
73  setup(name = "pyshapelib",  setup(name = "pyshapelib",
74        version = "0.3",          version = "0.3",
75        description = "Python bindings for shapelib",          description = "Python bindings for shapelib",
76        author = "Bernhard Herzog",          author = "Bernhard Herzog",
77        author_email = "[email protected]",          author_email = "[email protected]",
78        url = "ftp:intevation.de/users/bh",          url = "ftp:intevation.de/users/bh",
79        py_modules = ["shapelib", "dbflib"],          ext_modules = extensions)
       ext_modules = extensions)  
80    

Legend:
Removed from v.2212  
changed lines
  Added in v.2752

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26