1 |
# Copyright (c) 2001, 2002, 2003 by Intevation GmbH |
# Copyright (c) 2001, 2002, 2003, 2004, 2005 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
4 |
# |
# |
15 |
# hand below. |
# hand below. |
16 |
# |
# |
17 |
|
|
18 |
|
import sys |
19 |
import os |
import os |
20 |
from types import TupleType |
from types import TupleType |
21 |
import glob |
import glob |
82 |
################################################################# |
################################################################# |
83 |
# Windows configuration. |
# Windows configuration. |
84 |
# |
# |
85 |
|
|
86 |
|
basedir = os.path.dirname(sys.argv[0]) |
87 |
|
|
88 |
# Directories where Proj4 is installed |
# Directories where Proj4 is installed |
89 |
proj4_prefix = r"D:\cygwin\home\user\proj-4.4.3\src" |
proj4_prefix = os.path.join(basedir, "..", "proj-4.4.7", "src") |
90 |
proj4_incdir = proj4_prefix |
proj4_incdir = proj4_prefix |
91 |
proj4_libdir = proj4_prefix |
proj4_libdir = proj4_prefix |
92 |
proj4_lib = "proj_i" |
proj4_lib = "proj_i" |
93 |
|
|
94 |
# Define include and lib directories for wxWindows |
# Define include and lib directories for wxWindows and |
95 |
wx_prefix = r"D:\wx240" |
wx_prefix = os.path.join(basedir, "..", "wxPython-2.4.2.4") |
96 |
wx_inc = [os.path.join(wx_prefix, 'lib', 'mswdllh'), |
wx_inc = [os.path.join(wx_prefix, 'lib', 'mswdllh'), |
97 |
os.path.join(wx_prefix, "include")] |
os.path.join(wx_prefix, "include")] |
98 |
wx_lib = [os.path.join(wx_prefix, "lib")] |
wx_lib = [os.path.join(wx_prefix, "lib")] |
99 |
|
|
100 |
# Define include and lib directories for GDAL |
# Define include and lib directories for GDAL |
101 |
gdal_prefix = r"D:\cygwin\home\user\build\gdal-1.1.8" |
gdal_prefix = os.path.join(basedir, "..", "gdal-1.1.8") |
102 |
gdal_inc = [os.path.join(gdal_prefix, 'alg'), |
gdal_inc = [os.path.join(gdal_prefix, 'alg'), |
103 |
os.path.join(gdal_prefix, 'ogr'), |
os.path.join(gdal_prefix, 'ogr'), |
104 |
os.path.join(gdal_prefix, 'port'), |
os.path.join(gdal_prefix, 'port'), |
105 |
os.path.join(gdal_prefix, 'core')] |
os.path.join(gdal_prefix, 'core')] |
106 |
gdal_lib = gdal_prefix |
gdal_lib = [gdal_prefix] |
107 |
|
|
108 |
# |
# |
109 |
# Unless you use a wxPython version other than 2.4.0, you probably |
# Unless you use a wxPython version other than 2.4.0, you probably |
233 |
# |
# |
234 |
# Define some extension and python modules |
# Define some extension and python modules |
235 |
# |
# |
236 |
# The C-extension names are prefixed woth "Lib." so they get put into |
# The C-extension names are prefixed with "Lib." so they get put into |
237 |
# the Lib/ subdirectory. Lib/ is not really a package but distutils |
# the Lib/ subdirectory. Lib/ is not really a package but distutils |
238 |
# doesn't care |
# doesn't care |
239 |
|
|
240 |
# subdirectory containing the extensions |
# subdirectory containing the distutil extensions |
241 |
ext_dir = "extensions" |
ext_dir = "libraries" |
242 |
|
|
243 |
# subdirectory with some shapelib files |
# subdirectory with some shapelib files |
244 |
shp_dir = ext_dir + "/shapelib" |
shp_dir = ext_dir + "/shapelib" |
252 |
# Thuban specific modules |
# Thuban specific modules |
253 |
# |
# |
254 |
|
|
255 |
extensions.append(Extension("Lib.wxproj", |
wxproj_extension = Extension("Lib.wxproj", |
256 |
[ext_dir + "/thuban/wxproj.cpp"], |
[ext_dir + "/thuban/wxproj.cpp"], |
257 |
include_dirs = ([shp_dir, proj4_incdir, |
include_dirs = ([shp_dir, proj4_incdir, |
258 |
ext_dir + "/pyshapelib/"] |
ext_dir + "/pyshapelib/"] |
259 |
+ wx_cs_params[CS_INCDIRS]), |
+ wx_cs_params[CS_INCDIRS]), |
260 |
define_macros = wx_cs_params[CS_DEFS], |
define_macros = wx_cs_params[CS_DEFS], |
261 |
library_dirs = [proj4_libdir] + |
library_dirs = [proj4_libdir] + |
262 |
wx_cs_params[CS_LIBDIRS], |
wx_cs_params[CS_LIBDIRS], |
263 |
libraries = [proj4_lib] + wx_cs_params[CS_LIBS])) |
libraries = [proj4_lib] + wx_cs_params[CS_LIBS]) |
264 |
|
extensions.append(wxproj_extension) |
265 |
|
|
266 |
|
|
267 |
# |
# |
279 |
extensions.append(Extension("Lib.dbflibc", |
extensions.append(Extension("Lib.dbflibc", |
280 |
[ext_dir + "/pyshapelib/dbflib_wrap.c", |
[ext_dir + "/pyshapelib/dbflib_wrap.c", |
281 |
shp_dir + "/dbfopen.c"], |
shp_dir + "/dbfopen.c"], |
282 |
include_dirs = [shp_dir])) |
include_dirs = [shp_dir], |
283 |
|
define_macros = [("HAVE_UPDATE_HEADER", "1")])) |
284 |
for name in ("shapelib", "dbflib"): |
for name in ("shapelib", "dbflib"): |
285 |
py_modules.append(ext_dir + "/pyshapelib/" + name) |
py_modules.append(ext_dir + "/pyshapelib/" + name) |
286 |
|
|
301 |
|
|
302 |
data_files = [] |
data_files = [] |
303 |
|
|
304 |
# bitmaps |
# Resources |
305 |
for d, pattern in [("Resources/Bitmaps", "Resources/Bitmaps/*.xpm"), |
for d, patterns in [("Resources/Bitmaps", |
306 |
("Resources/Locale", "Resources/Locale/*/LC_MESSAGES/*.mo") |
("Resources/Bitmaps/*.xpm",)), |
307 |
|
("Resources/Projections", |
308 |
|
("Resources/Projections/*.proj",)), |
309 |
|
("Resources/XML", |
310 |
|
("Resources/XML/*.dtd",)), |
311 |
|
("Extensions/importAPR/samples", |
312 |
|
("Extensions/importAPR/samples/README", |
313 |
|
"Extensions/importAPR/samples/*.apr")), |
314 |
]: |
]: |
315 |
data_files.append((d, glob.glob(pattern))) |
for pattern in patterns: |
316 |
|
data_files.append((d, glob.glob(pattern))) |
317 |
|
if os.path.isdir("Resources/Locale"): |
318 |
|
for d in os.listdir("Resources/Locale"): |
319 |
|
data_files.append(("Resources/Locale/" + d +"/LC_MESSAGES", |
320 |
|
["Resources/Locale/"+ d +"/LC_MESSAGES/thuban.mo"])) |
321 |
|
|
322 |
# |
# |
323 |
# Command definitions |
# Command definitions |
799 |
|
|
800 |
bdist_rpm_prep_script = ''' |
bdist_rpm_prep_script = ''' |
801 |
%setup |
%setup |
802 |
cp extensions/pyshapelib/{README,README.pyshapelib} |
cp libraries/pyshapelib/{README,README.pyshapelib} |
803 |
cp extensions/pyshapelib/{COPYING,COPYING.pyshapelib} |
cp libraries/pyshapelib/{COPYING,COPYING.pyshapelib} |
804 |
cp extensions/pyprojection/{LICENSE,LICENSE.pyprojection} |
cp libraries/pyprojection/{LICENSE,LICENSE.pyprojection} |
805 |
''' |
''' |
806 |
|
|
807 |
bdist_rpm_build_script = ''' |
bdist_rpm_build_script = ''' |
1073 |
|
|
1074 |
class thuban_build_ext(build_ext): |
class thuban_build_ext(build_ext): |
1075 |
|
|
1076 |
"""Extend the build_ext command to optionally include the |
"""Extend the build_ext command with some Thuban specific options |
1077 |
GDAL extension. |
|
1078 |
|
--with-gdal, --without-gdal |
1079 |
|
|
1080 |
|
Switch the optional GDAL support on/off. Default is On. |
1081 |
|
|
1082 |
|
--use-wx-python-swig-hack |
1083 |
|
|
1084 |
|
For performance reasons, Thuban access wxPython objects at the |
1085 |
|
C++ level so that it can directly call wxWidgets code from C++. |
1086 |
|
The normal and preferred way to do that is to use the API |
1087 |
|
defined in wxPython.h. Unfortunately, this header file is not |
1088 |
|
distributed with binary packages of wxPython on some platforms. |
1089 |
|
By using the --use-wx-python-swig-hack option you can activate a |
1090 |
|
way to access the C++ objects without wxPython.h. This relies |
1091 |
|
on internals of SWIG, so it might change with future wxPython |
1092 |
|
versions. Therefore, only use this option if the normal way |
1093 |
|
doesn't work for you. |
1094 |
""" |
""" |
1095 |
|
|
1096 |
user_options = build_ext.user_options[:] |
user_options = build_ext.user_options[:] |
1097 |
user_options.extend([("with-gdal", None, "Include GDAL support."), |
user_options.extend([("with-gdal", None, "Include GDAL support."), |
1098 |
("without-gdal", None, "Don't include GDAL support.")]) |
("without-gdal", None, "Don't include GDAL support."), |
1099 |
|
("use-wx-python-swig-hack", None, |
1100 |
|
"Use a hack to access wxPython objects at the C++ level" |
1101 |
|
"(use only when you absolutely can't use wxPython.h)")]) |
1102 |
|
|
1103 |
boolean_options = ["with-gdal"] |
boolean_options = ["with-gdal", "use-wx-python-swig-hack"] |
1104 |
negative_opt = {'without-gdal' : 'with-gdal'} |
negative_opt = {'without-gdal' : 'with-gdal'} |
1105 |
|
|
1106 |
def initialize_options(self): |
def initialize_options(self): |
1107 |
self.with_gdal = True |
self.with_gdal = True |
1108 |
|
self.use_wx_python_swig_hack = False |
1109 |
build_ext.initialize_options(self) |
build_ext.initialize_options(self) |
1110 |
|
|
1111 |
def finalize_options(self): |
def finalize_options(self): |
1112 |
build_ext.finalize_options(self) |
build_ext.finalize_options(self) |
1113 |
if self.with_gdal and include_gdal: |
if self.with_gdal and include_gdal: |
1114 |
self.extensions.append(Extension("Lib.gdalwarp", |
self.extensions.append(Extension("Lib.gdalwarp", |
1115 |
[ext_dir + "/thuban/gdalwarp.cpp", |
[ext_dir + "/thuban/gdalwarp.cpp"], |
1116 |
ext_dir + "/thuban/cpl_mfile.cpp", |
include_dirs = gdal_cs_params[CS_INCDIRS] + |
1117 |
ext_dir + "/thuban/bmpdataset.cpp"], |
[ext_dir + "/thuban/"], |
|
include_dirs = ([gdal_cs_params[CS_INCDIRS], |
|
|
ext_dir + "/thuban/"]), |
|
1118 |
define_macros = gdal_cs_params[CS_DEFS], |
define_macros = gdal_cs_params[CS_DEFS], |
1119 |
library_dirs = gdal_cs_params[CS_LIBDIRS], |
library_dirs = gdal_cs_params[CS_LIBDIRS], |
1120 |
libraries = [proj4_lib] + |
libraries = gdal_cs_params[CS_LIBS])) |
1121 |
gdal_cs_params[CS_LIBS])) |
if self.use_wx_python_swig_hack: |
1122 |
|
wxproj_extension.define_macros.append(("USE_WX_PYTHON_SWIG_HACK", |
1123 |
|
None)) |
1124 |
|
|
1125 |
def run(self, install_options = None): |
def run(self, install_options = None): |
1126 |
build_ext.run(self) |
build_ext.run(self) |
1134 |
""" |
""" |
1135 |
|
|
1136 |
setup(name = "Thuban", |
setup(name = "Thuban", |
1137 |
version = "0.2.0", |
version = "1.0.0", |
1138 |
description = "Geographic data viewer", |
description = "Geographic data viewer", |
1139 |
long_description = long_description, |
long_description = long_description, |
1140 |
licence = "GPL", |
license = "GPL", |
1141 |
author = "Intevation GmbH", |
author = "Intevation GmbH", |
1142 |
author_email = "[email protected]", |
author_email = "[email protected]", |
1143 |
url = "http://thuban.intevation.de/", |
url = "http://thuban.intevation.de/", |
1144 |
|
|
1145 |
scripts = ["thuban.py"], |
scripts = ["thuban.py"], |
1146 |
packages = ["Thuban", "Thuban.Lib", "Thuban.Model", "Thuban.UI"], |
packages = ["Thuban", "Thuban.Lib", "Thuban.Model", "Thuban.UI", |
1147 |
|
"Extensions", "Extensions.gns2shp", "Extensions.wms", |
1148 |
|
"Extensions.importAPR", "Extensions.profiling"], |
1149 |
ext_modules = extensions, |
ext_modules = extensions, |
1150 |
py_modules = py_modules, |
py_modules = py_modules, |
1151 |
data_files = data_files, |
data_files = data_files, |