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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2212 - (show annotations)
Mon May 17 15:47:57 2004 UTC (20 years, 9 months ago) by bh
Original Path: trunk/thuban/libraries/pyshapelib/setup.py
File MIME type: text/x-python
File size: 2491 byte(s)
Update to newest shapelib and get rid of Thuban specific extensions,
i.e. use the new DBFUpdateHeader instead of our DBFCommit kludge

* libraries/shapelib/shpopen.c: Update to version from current
shapelib CVS.

* libraries/shapelib/shapefil.h: Update to version from current
shapelib CVS.

* libraries/shapelib/dbfopen.c: Update to version from current
shapelib CVS.
(DBFCommit): Effectively removed since shapelib itself has
DBFUpdateHeader now which is better for what DBFCommit wanted to
achieve.
We're now using an unmodified version of dbfopen.

* libraries/pyshapelib/dbflib_wrap.c, libraries/pyshapelib/dbflib.py:
Update from dbflib.i

* libraries/pyshapelib/dbflib.i (DBFInfo_commit): New. Implementation of
the commit method.  This new indirection is necessary because we use the
DBFUpdateHeader function now which is not available in shapelib <=
1.2.10
(DBFFile::commit): Use DBFInfo_commit as implementation
(pragma __class__): New. Kludge to remove the commit method when
the DBFUpdateHeader function isn't available
(_have_commit): New. Helper for the pragma kludge.

* libraries/pyshapelib/setup.py (dbf_macros): New. Return the
preprocessor macros needed to compile the dbflib wrapper.  Determine
whether DBFUpdateHeader is available and define the right value of
HAVE_UPDATE_HEADER
(extensions): Use dbf_macros for the dbflibc extension

* setup.py (extensions): Add the HAVE_UPDATE_HEADER macro with
value '1' to the Lib.dbflibc extension.  This simply reflects the
shapelib and pyshapelib updates

1
2 import os
3 from distutils.core import setup, Extension
4 from distutils.util import convert_path
5
6 # try to determine the directory where the shapelib source files are.
7 # There are currently two supported situations.
8 #
9 # 1. "Standalone" build: the parent directory is the shapelib source
10 # directory
11 # 2. Built in the Thuban source tree where ../shapelib/ relative to the
12 # directory containing this setup.py contains (the relevant parts of)
13 # shapelib
14
15 # os.path expects filenames in OS-specific form so we have to construct
16 # the files with os.path functions. distutils, OTOH, uses posix-style
17 # filenames exclusively, so we use posix conventions when making
18 # filenames for distutils.
19 for shp_dir in ["..", "../shapelib"]:
20 if os.path.exists(os.path.join(convert_path(shp_dir), "shpopen.c")):
21 # shp_dir contains shpopen.c, so assume it's the directory with
22 # the shapefile library to use
23 break
24
25 def dbf_macros():
26 """Return the macros to define when compiling the dbflib wrapper.
27
28 The returned list specifies one macro, HAVE_UPDATE_HEADER, which is
29 '1' if the dbflib version we will be compiling with has the
30 DBFUpdateHeader function and '0' otherwise. To check whether
31 DBFUpdateHeader is available, we scan shapefil.h for the string
32 'DBFUpdateHeader'.
33 """
34 f = open(convert_path(shp_dir + "/shapefil.h"))
35 contents = f.read()
36 f.close()
37 print contents.find("DBFUpdateHeader")
38 if contents.find("DBFUpdateHeader") >= 0:
39 return [("HAVE_UPDATE_HEADER", "1")]
40 else:
41 return [("HAVE_UPDATE_HEADER", "0")]
42
43 extensions = [Extension("shapelibc",
44 ["shapelib_wrap.c",
45 shp_dir + "/shpopen.c",
46 shp_dir + "/shptree.c"],
47 include_dirs = [shp_dir]),
48 Extension("shptree",
49 ["shptreemodule.c"],
50 include_dirs = [shp_dir]),
51 Extension("dbflibc",
52 ["dbflib_wrap.c",
53 shp_dir + "/dbfopen.c"],
54 include_dirs = [shp_dir],
55 define_macros = dbf_macros())]
56
57 setup(name = "pyshapelib",
58 version = "0.3",
59 description = "Python bindings for shapelib",
60 author = "Bernhard Herzog",
61 author_email = "[email protected]",
62 url = "ftp:intevation.de/users/bh",
63 py_modules = ["shapelib", "dbflib"],
64 ext_modules = extensions)
65

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26