1 |
# Copyright (c) 2001, 2002 by Intevation GmbH |
# Copyright (c) 2001, 2002, 2003 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
4 |
# |
# |
17 |
|
|
18 |
import os |
import os |
19 |
from types import TupleType |
from types import TupleType |
20 |
|
import glob |
21 |
from distutils.core import setup, Extension, Command |
from distutils.core import setup, Extension, Command |
22 |
from distutils.command.install import install, INSTALL_SCHEMES, subst_vars |
from distutils.command.install import install, INSTALL_SCHEMES, subst_vars |
23 |
from distutils.command.build_py import build_py |
from distutils.command.build_py import build_py |
81 |
proj4_lib = "proj_i" |
proj4_lib = "proj_i" |
82 |
|
|
83 |
# Define include and lib directories for wxWindows and |
# Define include and lib directories for wxWindows and |
84 |
wx_prefix = r"D:\wx230" |
wx_prefix = r"D:\wx240" |
85 |
wx_inc = os.path.join(wx_prefix, "include") |
wx_inc = [os.path.join(wx_prefix, 'lib', 'mswdllh'), |
86 |
wx_lib = os.path.join(wx_prefix, "lib") |
os.path.join(wx_prefix, "include")] |
87 |
|
wx_lib = [os.path.join(wx_prefix, "lib")] |
88 |
|
|
89 |
|
|
90 |
# |
# |
91 |
# Unless you use a wxPython version other than 2.3.1, you probably |
# Unless you use a wxPython version other than 2.4.0, you probably |
92 |
# shouldn't have to modify anything below here |
# shouldn't have to modify anything below here |
93 |
################################################################## |
################################################################## |
94 |
|
|
130 |
('WXP_USE_THREAD', '1'), |
('WXP_USE_THREAD', '1'), |
131 |
] |
] |
132 |
|
|
133 |
wx_incdirs = [wx_inc] |
wx_incdirs = wx_inc |
134 |
wx_libdirs = [wx_lib] |
wx_libdirs = wx_lib |
135 |
wx_libs = ["wx23_1h"] |
wx_libs = ["wxmsw24h"] |
136 |
|
|
137 |
wx_libs = wx_libs + ['kernel32', 'user32', 'gdi32', 'comdlg32', |
wx_libs = wx_libs + ['kernel32', 'user32', 'gdi32', 'comdlg32', |
138 |
'winspool', 'winmm', 'shell32', 'oldnames', |
'winspool', 'winmm', 'shell32', 'oldnames', |
139 |
'comctl32', 'ctl3d32', 'odbc32', 'ole32', 'oleaut32', |
'comctl32', 'ctl3d32', 'odbc32', 'ole32', 'oleaut32', |
228 |
library_dirs = [proj4_libdir] + wx_libdirs, |
library_dirs = [proj4_libdir] + wx_libdirs, |
229 |
libraries = [proj4_lib] + wx_libs)) |
libraries = [proj4_lib] + wx_libs)) |
230 |
|
|
231 |
|
extensions.append(Extension("Lib.gdalwarp", |
232 |
|
[ext_dir + "/thuban/gdalwarp.cpp", |
233 |
|
ext_dir + "/thuban/cpl_mfile.cpp", |
234 |
|
ext_dir + "/thuban/bmpdataset.cpp"], |
235 |
|
libraries = [proj4_lib] + ["gdal.1.1"])) |
236 |
|
|
237 |
|
|
238 |
# |
# |
239 |
# shapelib wrappers are also distributed with thuban |
# shapelib wrappers are also distributed with thuban |
240 |
# |
# |
272 |
data_files = [] |
data_files = [] |
273 |
|
|
274 |
# bitmaps |
# bitmaps |
275 |
dir = "Resources/Bitmaps" |
for d, pattern in [("Resources/Bitmaps", "Resources/Bitmaps/*.xpm"), |
276 |
bitmaps = [] |
("Resources/Locale", "Resources/Locale/*/LC_MESSAGES/*.mo") |
277 |
for file in os.listdir(os.path.join("Resources", "Bitmaps")): |
]: |
278 |
if string.lower(file[-4:]) == ".xpm": |
data_files.append((d, glob.glob(pattern))) |
|
bitmaps.append(dir + '/' + file) |
|
|
data_files.append((dir, bitmaps)) |
|
279 |
|
|
280 |
# |
# |
281 |
# Command definitions |
# Command definitions |
497 |
distribution. |
distribution. |
498 |
""" |
""" |
499 |
|
|
500 |
|
# FIXME: When Thuban can rely on Python 2.3 as the oldest supported |
501 |
|
# Python release we don't need to override the run and |
502 |
|
# find_all_modules methods anymore. distutils will allow both python |
503 |
|
# modules and packages starting with 2.3. |
504 |
|
|
505 |
def run(self): |
def run(self): |
506 |
"""The same the as the original in build_py revision 1.33 except |
"""The same the as the original in build_py revision 1.33 except |
507 |
that this allows both packages and modules to be in one |
that this allows both packages and modules to be in one |
685 |
src, dest = item |
src, dest = item |
686 |
else: |
else: |
687 |
src = dest = item |
src = dest = item |
688 |
self.copy_file(convert_path(src), |
self.copy_file(convert_path(src), |
689 |
os.path.join(self.root, convert_path(dest))) |
os.path.join(self.root, convert_path(dest))) |
690 |
|
|
691 |
if os.name == "posix" and self.do_symlink: |
if os.name == "posix" and self.do_symlink: |
705 |
initfilename = self.thuban_init_filename() |
initfilename = self.thuban_init_filename() |
706 |
if self.root: |
if self.root: |
707 |
initfilename = change_root(self.root, initfilename) |
initfilename = change_root(self.root, initfilename) |
708 |
contents = thubaninit_contents(repr(self.install_lib_orig)) |
contents = thubaninit_contents(self.install_lib_orig) |
709 |
self.mkpath(os.path.dirname(initfilename)) |
self.mkpath(os.path.dirname(initfilename)) |
710 |
self.execute(write_file, (initfilename, contents), |
self.execute(write_file, (initfilename, contents), |
711 |
"Create %s" % initfilename) |
"Create %s" % initfilename) |
762 |
cp extensions/pyprojection/{LICENSE,LICENSE.pyprojection} |
cp extensions/pyprojection/{LICENSE,LICENSE.pyprojection} |
763 |
''' |
''' |
764 |
|
|
765 |
|
bdist_rpm_build_script = ''' |
766 |
|
env PATH="$PATH:%(prefix)s/lib/wxPython/bin:/usr/lib/wxPython/bin" CFLAGS="$RPM_OPT_FLAGS" %(python)s setup.py build |
767 |
|
''' |
768 |
|
|
769 |
bdist_rpm_install_script = ''' |
bdist_rpm_install_script = ''' |
770 |
%(python)s setup.py install --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES \ |
%(python)s setup.py install --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES \ |
771 |
--prefix=%(prefix)s |
--prefix=%(prefix)s |
772 |
''' |
''' |
773 |
|
|
774 |
|
|
775 |
class thuban_bdist_rpm(bdist_rpm): |
class thuban_bdist_rpm(bdist_rpm): |
776 |
|
|
777 |
"""Thuban specific RPM distribution command""" |
"""Thuban specific RPM distribution command""" |
789 |
# scripts such as the python interpreter to use are only known |
# scripts such as the python interpreter to use are only known |
790 |
# then. |
# then. |
791 |
open("bdist_rpm_prep", "w").close() |
open("bdist_rpm_prep", "w").close() |
792 |
|
open("bdist_rpm_build", "w").close() |
793 |
open("bdist_rpm_install", "w").close() |
open("bdist_rpm_install", "w").close() |
794 |
bdist_rpm.initialize_options(self) |
bdist_rpm.initialize_options(self) |
795 |
|
|
797 |
# create the scripts for the spec-file. Now we know the python |
# create the scripts for the spec-file. Now we know the python |
798 |
# interpreter to use. |
# interpreter to use. |
799 |
open("bdist_rpm_prep", "w").write(bdist_rpm_prep_script) |
open("bdist_rpm_prep", "w").write(bdist_rpm_prep_script) |
800 |
|
|
801 |
|
build = bdist_rpm_build_script % {"python": self.python, |
802 |
|
"prefix": self.prefix} |
803 |
|
open("bdist_rpm_build", "w").write(build) |
804 |
|
|
805 |
install = bdist_rpm_install_script % {"python": self.python, |
install = bdist_rpm_install_script % {"python": self.python, |
806 |
"prefix": self.prefix} |
"prefix": self.prefix} |
807 |
open("bdist_rpm_install", "w").write(install) |
open("bdist_rpm_install", "w").write(install) |
889 |
"""Execute the command. install_options if given, should be a |
"""Execute the command. install_options if given, should be a |
890 |
directory of additional options to set in the install step""" |
directory of additional options to set in the install step""" |
891 |
# Obviously have to build before we can install |
# Obviously have to build before we can install |
892 |
|
|
893 |
if not self.skip_build: |
if not self.skip_build: |
894 |
self.run_command('build') |
self.run_command('build') |
895 |
|
|
912 |
self.execute(write_file, (iss_file, self.generate_iss()), |
self.execute(write_file, (iss_file, self.generate_iss()), |
913 |
"Create Inno Setup script file %s" % iss_file) |
"Create Inno Setup script file %s" % iss_file) |
914 |
|
|
915 |
# and invoke |
# and invoke |
916 |
if self.run_inno: |
if self.run_inno: |
917 |
self.spawn(["iscc", iss_file]) |
self.spawn(["iscc", iss_file]) |
918 |
|
|
978 |
line = 'Name: "{group}\\%s"; Filename: "%s";' \ |
line = 'Name: "{group}\\%s"; Filename: "%s";' \ |
979 |
% (icon.title, icon.install_name) |
% (icon.title, icon.install_name) |
980 |
iss.append(line) |
iss.append(line) |
981 |
|
|
982 |
return iss |
return iss |
983 |
|
|
984 |
|
|
994 |
else: |
else: |
995 |
self.install_name = filename |
self.install_name = filename |
996 |
|
|
997 |
|
|
998 |
class thuban_bdist_inno(bdist_inno): |
class thuban_bdist_inno(bdist_inno): |
999 |
|
|
1000 |
"""Thuban specific Inno Setup stuff""" |
"""Thuban specific Inno Setup stuff""" |
1002 |
def run(self): |
def run(self): |
1003 |
install_options = { |
install_options = { |
1004 |
"prefix": ".", |
"prefix": ".", |
1005 |
|
"install_lib": "$base", |
1006 |
|
"install_data": "$base", |
1007 |
"install_scripts": "$base", |
"install_scripts": "$base", |
1008 |
"warn_dir": 0, |
"warn_dir": 0, |
1009 |
"extra_files": ["COPYING", "Lib/proj.dll"], |
"extra_files": ["COPYING", "Lib/proj.dll"], |
1011 |
# don't make a symlink because we're simulating windows, so |
# don't make a symlink because we're simulating windows, so |
1012 |
# that we can generate the iss-file even on Linux |
# that we can generate the iss-file even on Linux |
1013 |
install_options["do_symlink"] = 0 |
install_options["do_symlink"] = 0 |
1014 |
|
|
1015 |
bdist_inno.run(self, install_options) |
bdist_inno.run(self, install_options) |
1016 |
|
|
1017 |
|
class thuban_build_docs(Command): |
1018 |
|
|
1019 |
|
"""Command to generate documentation from source code.""" |
1020 |
|
|
1021 |
|
description = "Generate documentation." |
1022 |
|
|
1023 |
|
user_options = [] |
1024 |
|
|
1025 |
|
def initialize_options(self): pass |
1026 |
|
|
1027 |
|
def finalize_options(self): pass |
1028 |
|
|
1029 |
|
def run(self, install_options = None): |
1030 |
|
self.spawn(["happydoc", "-d./Doc", "./Thuban"]) |
1031 |
|
|
1032 |
# |
# |
1033 |
# Run the script |
# Run the script |
1034 |
# |
# |
1039 |
""" |
""" |
1040 |
|
|
1041 |
setup(name = "Thuban", |
setup(name = "Thuban", |
1042 |
version = "0.1.3cvs", |
version = "0.2.0", |
1043 |
description = "Geographic data viewer", |
description = "Geographic data viewer", |
1044 |
long_description = long_description, |
long_description = long_description, |
1045 |
licence = "GPL", |
licence = "GPL", |
1081 |
"install": ThubanInstall, |
"install": ThubanInstall, |
1082 |
"bdist_rpm": thuban_bdist_rpm, |
"bdist_rpm": thuban_bdist_rpm, |
1083 |
"bdist_inno": thuban_bdist_inno, |
"bdist_inno": thuban_bdist_inno, |
1084 |
"data_dist": data_dist |
"data_dist": data_dist, |
1085 |
|
"build_docs": thuban_build_docs |
1086 |
}) |
}) |
1087 |
|
|
1088 |
|
|