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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 164 - (show annotations)
Fri May 10 09:34:40 2002 UTC (22 years, 10 months ago) by bh
Original Path: trunk/thuban/setup.py
File MIME type: text/x-python
File size: 30262 byte(s)
	* setup.py (py_modules): The shptree modules doesn't have a
	wrapper, so don't include it in the py_modules

1 # Copyright (c) 2001, 2002 by Intevation GmbH
2 # Authors:
3 # Bernhard Herzog <[email protected]>
4 #
5 # This program is free software under the GPL (>=v2)
6 # Read the file COPYING coming with Thuban for details.
7
8 """Distutils setup script for Thuban."""
9
10 __version__ = "$Revision$"
11
12 # Configuration:
13 #
14 # depending on your platform you may have to configure some variables by
15 # hand below.
16 #
17
18 import os
19 from types import TupleType
20 from distutils.core import setup, Extension, Command
21 from distutils.command.install import install
22 from distutils.command.build_py import build_py
23 from distutils.command.bdist_rpm import bdist_rpm
24 from distutils.file_util import write_file
25 from distutils.filelist import FileList
26 from distutils.util import convert_path, change_root
27
28 from distutils import archive_util, dir_util
29 import distutils
30
31 from string import split
32 import string
33
34 if os.name == "posix":
35 ###################################################################
36 # Posix configuration. Adapt this if you're running some kind of
37 # Unix like system.
38
39 # Directories where Proj4 is installed
40 proj4_prefix = "/usr/local/"
41 proj4_incdir = os.path.join(proj4_prefix, "include")
42 proj4_libdir = os.path.join(proj4_prefix, "lib")
43 proj4_lib = "proj"
44
45
46 # You shpuldn't have to modify anything below here
47 ###################################################################
48
49 # The installation prefix (similar to autoconf's --prefix). This is
50 # only the default value, you can override it on the command line
51 # with the install command's --prefix option
52 prefix = "/usr/local/"
53
54 # On POSIX-systems we run wxgtk-config to determine the C++-compiler
55 # flags
56 wx_config_script = "wx-config"
57 # These lists will be filled automatically below
58 wx_defs = []
59 wx_incdirs = []
60 wx_libdirs = []
61 wx_libs = []
62
63 elif os.name == "nt":
64 #################################################################
65 # Windows configuration.
66 #
67
68 # Directories where Proj4 is installed
69 proj4_prefix = r"D:\cygwin\home\user\proj-4.4.3\src"
70 proj4_incdir = proj4_prefix
71 proj4_libdir = proj4_prefix
72 proj4_lib = "proj_i"
73
74 # Define include and lib directories for wxWindows and
75 wx_prefix = r"D:\wx230"
76 wx_inc = os.path.join(wx_prefix, "include")
77 wx_lib = os.path.join(wx_prefix, "lib")
78
79 #
80 # Unless you use a wxPython version other than 2.3.1, you probably
81 # shouldn't have to modify anything below here
82 ##################################################################
83
84 # Installation prefix. Just install relative to current directory by
85 # default. This is only the default value, you can override it on
86 # the command line with the install command's --prefix option
87 prefix = r"install"
88
89 # There doesn't seem to be an easy way to get at the wx compiler
90 # flags, so we define them here. These flags work for us with
91 # wxPython 2.3.1. They may have to be modified for other versions.
92
93 # there's no config script.
94 wx_config_script = ""
95
96 # the values of wx_defs and wx_libs. copied from the wxPython
97 # setup.py
98 wx_defs = [ ('WIN32', None), # Some of these are no longer
99 ('__WIN32__', None), # necessary. Anybody know which?
100 ('_WINDOWS', None),
101 ('__WINDOWS__', None),
102 ('WINVER', '0x0400'),
103 ('__WIN95__', None),
104 ('STRICT', None),
105
106 ('__WXMSW__', None),
107 ('WXUSINGDLL', '1'),
108
109 ('SWIG_GLOBAL', None),
110 ('HAVE_CONFIG_H', None),
111 ('WXP_USE_THREAD', '1'),
112 ]
113
114 wx_incdirs = [wx_inc]
115 wx_libdirs = [wx_lib]
116 wx_libs = ["wx23_1h"]
117 wx_libs = wx_libs + ['kernel32', 'user32', 'gdi32', 'comdlg32',
118 'winspool', 'winmm', 'shell32', 'oldnames',
119 'comctl32', 'ctl3d32', 'odbc32', 'ole32', 'oleaut32',
120 'uuid', 'rpcrt4', 'advapi32', 'wsock32']
121 else:
122 raise RuntimeError("Unsupported platform " + os.name)
123
124
125 ######################################################################
126 #
127 # There's nothing beyond this point that has to be modified for a
128 # normal installation
129 #
130 ######################################################################
131
132
133 #
134 # Functions to determine wxWindows config on POSIX systems
135 #
136
137 def run_script(cmdline):
138 """Run command and return its stdout or none in case of errors"""
139 pipe = os.popen(cmdline)
140 result = pipe.read()
141 if pipe.close() is not None:
142 print '"' + cmdline + '"', 'failed'
143 return None
144 return result
145
146
147 def run_wx_script(command):
148 # first, determine the C++ preprocessor flags Use --cflags here
149 # because it seems that older version don't have --cxxflags and
150 # newer ones return the same result for both
151 flags = run_script(command + ' --cflags ')
152 if flags is None:
153 return 0
154 for flag in split(flags):
155 start = flag[:2]
156 value = flag[2:]
157 if start == "-I":
158 wx_incdirs.append(value)
159 elif start == "-D":
160 wx_defs.append((value, None))
161
162 # determine the library flags
163 flags = run_script(command + ' --libs')
164 if flags is None:
165 return 0
166 for flag in split(flags):
167 start = flag[:2]
168 value = flag[2:]
169 if start == "-L":
170 wx_libdirs.append(value)
171 elif start == "-l":
172 wx_libs.append(value)
173
174 if wx_config_script:
175 # if there's a wx config script, run it to determine the configuration
176 run_wx_script(wx_config_script)
177
178
179
180 #
181 # Define some extension and python modules
182 #
183 # The C-extension names are prefixed woth "Lib." so they get put into
184 # the Lib/ subdirectory. Lib/ is not really a package but distutils
185 # doesn't care
186
187 # subdirectory containing the extensions
188 ext_dir = "extensions"
189
190 # subdirectory with some shapelib files
191 shp_dir = ext_dir + "/shapelib"
192
193 # lists to fill with the module descriptions
194 extensions = []
195 py_modules = []
196
197
198 #
199 # Thuban specific modules
200 #
201
202 extensions.append(Extension("Lib.wxproj",
203 [ext_dir + "/thuban/wxproj.cpp"],
204 include_dirs = ([shp_dir, proj4_incdir,
205 ext_dir + "/pyshapelib/"]
206 + wx_incdirs),
207 define_macros = wx_defs,
208 library_dirs = [proj4_libdir] + wx_libdirs,
209 libraries = [proj4_lib] + wx_libs))
210
211 #
212 # shapelib wrappers are also distributed with thuban
213 #
214
215 extensions.append(Extension("Lib.shapelibc",
216 [ext_dir + "/pyshapelib/shapelib_wrap.c",
217 shp_dir + "/shpopen.c",
218 shp_dir + "/shptree.c"],
219 include_dirs = [shp_dir]))
220 extensions.append(Extension("Lib.shptree",
221 [ext_dir + "/pyshapelib/shptreemodule.c"],
222 include_dirs = [shp_dir]))
223 extensions.append(Extension("Lib.dbflibc",
224 [ext_dir + "/pyshapelib/dbflib_wrap.c",
225 shp_dir + "/dbfopen.c"],
226 include_dirs = [shp_dir]))
227 for name in ("shapelib", "dbflib"):
228 py_modules.append(ext_dir + "/pyshapelib/" + name)
229
230 #
231 # PROJ4 bindings are also distributed with thuban
232 #
233 extensions.append(Extension("Lib.Projectionc",
234 [ext_dir + "/pyprojection/Projection_wrap.c"],
235 include_dirs = [proj4_incdir],
236 library_dirs = [proj4_libdir],
237 libraries = [proj4_lib]))
238 py_modules.append(ext_dir + "/pyprojection/Projection")
239
240
241 #
242 # Data files
243 #
244
245 data_files = []
246
247 # bitmaps
248 dir = "Resources/Bitmaps"
249 bitmaps = []
250 for file in os.listdir(os.path.join("Resources", "Bitmaps")):
251 if string.lower(file[-4:]) == ".xpm":
252 bitmaps.append(dir + '/' + file)
253 data_files.append((dir, bitmaps))
254
255 #
256 # Command definitions
257 #
258 # So far distutils are only meant to distribute python extensions, not
259 # complete applications, so we have to redefine a few commands
260 #
261
262
263 # Much of the data_dist command is directly copied from the distutils'
264 # sdist command
265 class data_dist(Command):
266
267 description = "create a data distribution (tarball, zip file, etc.)"
268
269 user_options = [
270 ('formats=', None,
271 "formats for source distribution (comma-separated list)"),
272 ('keep-temp', 'k',
273 "keep the distribution tree around after creating " +
274 "archive file(s)"),
275 ('dist-dir=', 'd',
276 "directory to put the source distribution archive(s) in "
277 "[default: dist]"),
278 ]
279
280 boolean_options = ['keep-temp']
281
282 def initialize_options (self):
283 self.formats = None
284 self.keep_temp = 0
285 self.dist_dir = None
286
287 def finalize_options (self):
288 self.ensure_string_list('formats')
289 if self.formats is None:
290 self.formats = ["zip"]
291 bad_format = archive_util.check_archive_formats(self.formats)
292 if bad_format:
293 raise DistutilsOptionError, \
294 "unknown archive format '%s'" % bad_format
295
296 if self.dist_dir is None:
297 self.dist_dir = "dist"
298
299
300 def run(self):
301 # 'filelist' contains the list of files that will make up the
302 # manifest
303 self.filelist = FileList()
304
305 # Do whatever it takes to get the list of files to process.
306 # File list is accumulated in 'self.filelist'.
307 self.get_file_list()
308
309 # Otherwise, go ahead and create the source distribution tarball,
310 # or zipfile, or whatever.
311 self.make_distribution()
312
313 def get_file_list(self):
314 """Figure out the list of files to include in the data
315 distribution, and put it in 'self.filelist'.
316 """
317 self.filelist.findall("Data")
318 self.filelist.include_pattern("*", anchor = 0)
319 self.filelist.exclude_pattern(r'/(RCS|CVS)/.*', is_regex=1)
320 self.filelist.sort()
321 self.filelist.remove_duplicates()
322
323 def make_release_tree(self, base_dir, files):
324 """Create the directory tree that will become the source
325 distribution archive. All directories implied by the filenames in
326 'files' are created under 'base_dir', and then we hard link or copy
327 (if hard linking is unavailable) those files into place.
328 Essentially, this duplicates the developer's source tree, but in a
329 directory named after the distribution, containing only the files
330 to be distributed.
331 """
332 # Create all the directories under 'base_dir' necessary to
333 # put 'files' there; the 'mkpath()' is just so we don't die
334 # if the manifest happens to be empty.
335 self.mkpath(base_dir)
336 dir_util.create_tree(base_dir, files,
337 verbose=self.verbose, dry_run=self.dry_run)
338
339 # And walk over the list of files, either making a hard link (if
340 # os.link exists) to each one that doesn't already exist in its
341 # corresponding location under 'base_dir', or copying each file
342 # that's out-of-date in 'base_dir'. (Usually, all files will be
343 # out-of-date, because by default we blow away 'base_dir' when
344 # we're done making the distribution archives.)
345
346 if hasattr(os, 'link'): # can make hard links on this system
347 link = 'hard'
348 msg = "making hard links in %s..." % base_dir
349 else: # nope, have to copy
350 link = None
351 msg = "copying files to %s..." % base_dir
352
353 if not files:
354 self.warn("no files to distribute -- empty manifest?")
355 else:
356 self.announce(msg)
357 for file in files:
358 if not os.path.isfile(file):
359 self.warn("'%s' not a regular file -- skipping" % file)
360 else:
361 dest = os.path.join(base_dir, file)
362 self.copy_file(file, dest, link=link)
363
364
365 def make_distribution (self):
366 """Create the source distribution(s). First, we create the release
367 tree with 'make_release_tree()'; then, we create all required
368 archive files (according to 'self.formats') from the release tree.
369 Finally, we clean up by blowing away the release tree (unless
370 'self.keep_temp' is true). The list of archive files created is
371 stored so it can be retrieved later by 'get_archive_files()'.
372 """
373 # Don't warn about missing meta-data here -- should be (and is!)
374 # done elsewhere.
375 base_dir = "Thuban-data-" + self.distribution.get_version()
376 base_name = os.path.join(self.dist_dir, base_dir)
377
378 self.make_release_tree(base_dir, self.filelist.files)
379 archive_files = [] # remember names of files we create
380 for fmt in self.formats:
381 file = self.make_archive(base_name, fmt, base_dir=base_dir)
382 archive_files.append(file)
383
384 self.archive_files = archive_files
385
386 if not self.keep_temp:
387 dir_util.remove_tree(base_dir, self.verbose, self.dry_run)
388
389
390
391 class InstallLocal(Command):
392
393 """
394 A new install command to just link (or copy, on non-POSIX systems)
395 the extension modules to the top directory so that Thuban can be run
396 directly from the source dir.
397 """
398
399 description =\
400 "Create some symlinks so you can run thuban from the source directory"
401
402 user_options = [
403 ('skip-build', None, "skip the build steps"),
404 ]
405
406 def initialize_options (self):
407 self.extensions = None
408 self.build_dir = None
409 self.skip_build = None
410
411 def finalize_options (self):
412 self.set_undefined_options("install",
413 ("build_lib", "build_dir"),
414 ('skip_build', 'skip_build'))
415 self.extensions = self.distribution.ext_modules
416
417 def run(self):
418 # Make sure we have built everything we need first
419 self.build()
420
421 # now do the work. Simply link or copy the Lib dir
422 libdir = os.path.join(self.build_dir, "Lib")
423 if os.name == "posix":
424 # on posix, just link the Lib dir
425 self.link_dir(libdir, "Lib")
426 else:
427 self.copy_tree(libdir, "Lib")
428
429 def link_dir(self, src, dest):
430 """Create a symbolic link dest pointing to src"""
431 if self.verbose:
432 self.announce("symlinking %s -> %s" % (src, dest))
433 if self.dry_run:
434 return
435
436 if not (os.path.exists(dest) and os.path.samefile(src, dest)):
437 os.symlink(src, dest)
438
439 def build (self):
440 if not self.skip_build:
441 if self.distribution.has_pure_modules():
442 self.run_command('build_py')
443 if self.distribution.has_ext_modules():
444 self.run_command('build_ext')
445
446
447
448 class thuban_build_py(build_py):
449
450 """
451 A new build_py that can deal with both packages and modules in one
452 distribution.
453 """
454
455 def run(self):
456 """The same the as the original in build_py revision 1.33 except
457 that this allows both packages and modules to be in one
458 distribution
459 """
460 if not self.py_modules and not self.packages:
461 return
462
463 # Now we're down to two cases: 'py_modules' only and 'packages' only.
464 if self.py_modules:
465 self.build_modules()
466 if self.packages:
467 self.build_packages()
468
469 self.byte_compile(self.get_outputs(include_bytecode=0))
470
471 def find_modules (self):
472 """Thuban specific version of build_py.find_modules. Unlike the
473 original version, we assume that the modules in self.py_modules
474 can contain directories and are all to be placed into the same
475 subdirectory, Lib, in the build directory. This is achieved by
476 returning the modules as a list (package, module, filename)
477 where package is 'Lib', module is the basename of the module name
478 and filename is the filename relative to the package root.
479 """
480 modules = []
481 for module in self.py_modules:
482 module_base = os.path.basename(module)
483 module_file = module + ".py"
484 if not self.check_module(module, module_file):
485 continue
486
487 modules.append(("Lib", module_base, module_file))
488 return modules
489
490 def find_all_modules (self):
491 # same as find_all_modules of the original build_py command
492 # (rev. 1.33) but handle installations with both modules and
493 # packages. Needed here so tha the get_outputs works correctly
494 modules = []
495 if self.py_modules:
496 modules.extend(self.find_modules())
497 if self.packages:
498 for package in self.packages:
499 package_dir = self.get_package_dir(package)
500 m = self.find_package_modules(package, package_dir)
501 modules.extend(m)
502
503 return modules
504
505
506
507 class ThubanInstall(install):
508
509 """
510 Thuban specific install command.
511
512 Extend the standard install command to symlink the installed script
513 to $prefix/bin/
514 """
515
516 user_options = install.user_options[:]
517 user_options.extend([("do-symlink", None,
518 "Create a symlink to the script in <prefix>/bin."
519 "(default on posix systems and only relevant there)"),
520
521 ("extra-files", None,
522 "List of filenames or (src, dest) pairs describing "
523 " extra files to install "
524 "(can only be set from witin setup.py"),
525 ])
526
527 boolean_options = install.boolean_options[:]
528 boolean_options.append("do-symlink")
529
530 def initialize_options(self):
531 self.do_symlink = None
532 self.extra_files = []
533 install.initialize_options(self)
534
535 def finalize_options(self):
536 if self.do_symlink is None:
537 if os.name == "posix":
538 self.do_symlink = 1
539 else:
540 self.do_symlink = 0
541 install.finalize_options(self)
542
543 def run(self):
544 install.run(self)
545 for item in self.extra_files:
546 if type(item) == TupleType:
547 src, dest = item
548 else:
549 src = dest = item
550 self.copy_file(convert_path(src),
551 os.path.join(self.root, convert_path(dest)))
552
553 if os.name == "posix" and self.do_symlink:
554 install_scripts = self.install_scripts
555 if self.root:
556 install_scripts = install_scripts[len(self.root):]
557 scriptfile = os.path.join(install_scripts, "thuban.py")
558 bindir = os.path.join(self.prefix, "bin")
559 if self.root:
560 bindir = change_root(self.root, bindir)
561 binfile = os.path.join(bindir, "thuban")
562 self.mkpath(bindir)
563 self.link_file(scriptfile, binfile)
564
565 def link_file(self, src, dest):
566 """Create a symbolic link dest pointing to src.
567
568 Unlike the symlink variant of the command object's copy_file
569 method, this method even performs the link if src doesn't exist.
570 This is useful when installing with an alternat root directory"""
571 if self.verbose:
572 self.announce("symlinking %s -> %s" % (src, dest))
573 if self.dry_run:
574 return
575
576 if not os.path.exists(dest):
577 os.symlink(src, dest)
578
579
580 def get_outputs (self):
581 outputs = install.get_outputs(self)
582 for item in self.extra_files:
583 if type(item) == TupleType:
584 src, dest = item
585 else:
586 src = dest = item
587 outputs.append(os.path.join(self.root, convert_path(dest)))
588 if os.name == "posix" and self.do_symlink:
589 bindir = os.path.join(self.prefix, "bin")
590 if self.root:
591 bindir = change_root(self.root, bindir)
592 binfile = os.path.join(bindir, "thuban")
593 outputs.append(binfile)
594 return outputs
595
596
597 bdist_rpm_prep_script = '''
598 %setup
599 cp extensions/pyshapelib/{README,README.pyshapelib}
600 cp extensions/pyshapelib/{COPYING,COPYING.pyshapelib}
601 cp extensions/pyprojection/{LICENSE,LICENSE.pyprojection}
602 '''
603
604
605
606 class thuban_bdist_rpm(bdist_rpm):
607
608 """Thuban specific RPM distribution command"""
609
610 def initialize_options(self):
611 # create the prep script for the spec-file
612 open("bdist_rpm_prep", "w").write(bdist_rpm_prep_script)
613
614 bdist_rpm.initialize_options(self)
615
616
617 class bdist_inno(Command):
618
619 """Command to create a windows installer with Inno Setup"""
620
621 description = "Create a windows installer with Inno Setup"
622
623 user_options = [
624 ('skip-build', None, "skip the build steps"),
625 ('bdist-dir=', None,
626 "temporary directory for creating the distribution"),
627 ('run-inno', None,
628 "Run inno-setup to create the installer. On by default on nt"),
629 ('iss-name', None,
630 "The name of the iss file to generate. "
631 "Shouldn't contain directories"),
632
633 # Parameters for the Inno Setup script
634 ('copyright', None, "Copyright notice for the Inno Setup file"),
635 ('default-dir-name', None,
636 "Default installation directory. Defaults to '{pf}\\<name>'"),
637 ('default-group-name', None,
638 "Default program group name. Defaults to <name>'"),
639 ("license-file", None, "File containing the license."),
640 ("output-basename", None,
641 "Base filename for the Inno Setup output "
642 "(defaults to <name>-<version>-<issrevision>)."),
643 ("iss-revision", None,
644 "revision of the generated installer of the package version"),
645
646 ("icons-entries", None,
647 "List if InnoIconItems "
648 "(this can only be set from inside the setup.py script)"),
649 ]
650
651 boolean_options = ["do-symlink"]
652
653 def initialize_options(self):
654 self.skip_build = 0
655 self.bdist_dir = None
656 self.run_inno = None
657 self.iss_name = None
658 self.copyright = ""
659 self.default_dir_name = None
660 self.default_group_name = None
661 self.license_file = None
662 self.output_basename = None
663 self.iss_revision = None
664 self.icons_entries = []
665
666 def finalize_options(self):
667 self.set_undefined_options("install",
668 ('skip_build', 'skip_build'))
669 if self.bdist_dir is None:
670 bdist_base = self.get_finalized_command('bdist').bdist_base
671 self.bdist_dir = os.path.join(bdist_base, 'inno')
672
673 if self.run_inno is None:
674 self.run_inno = os.name == "nt"
675
676 name = self.distribution.get_name()
677 if self.iss_name is None:
678 self.iss_name = name + '.iss'
679
680 if self.default_dir_name is None:
681 self.default_dir_name = "{pf}\\" + name
682 if self.default_group_name is None:
683 self.default_group_name = name
684
685 if self.iss_revision is None:
686 self.iss_revision = 0
687 if self.output_basename is None:
688 self.output_basename = "%s-%s-%d" \
689 % (name, self.distribution.get_version(),
690 self.iss_revision)
691
692 def run(self, install_options = None):
693 """Execute the command. install_options if given, should be a
694 directory of additional options to set in the install step"""
695 # Obviously have to build before we can install
696 if not self.skip_build:
697 self.run_command('build')
698
699 # Install in a temporary directory
700 install = self.reinitialize_command('install')
701 install.root = self.bdist_dir
702 if install_options is not None:
703 for key, value in install_options.items():
704 setattr(install, key, value)
705 if os.name != 'nt':
706 # Must force install to use the 'nt' scheme;
707 install.select_scheme('nt')
708
709 self.announce("installing to %s" % self.bdist_dir)
710 install.ensure_finalized()
711 install.run()
712
713 # Create the iss file
714 iss_file = os.path.join(self.bdist_dir, self.iss_name)
715 self.execute(write_file, (iss_file, self.generate_iss()),
716 "Create Inno Setup script file %s" % iss_file)
717
718 # and invoke
719 if self.run_inno:
720 self.spawn(["iscc", iss_file])
721
722 def generate_iss(self):
723 """Return the contents of the iss file as list of strings, one
724 string per line"""
725
726 # first, turn the icons entries into a more usable form
727 icons = {}
728 for item in self.icons_entries:
729 icons[item.filename] = item
730
731 iss = []
732
733 name = self.distribution.get_name()
734 iss.extend(["[Setup]",
735 "AppName=" + name,
736 "AppVerName=" + name + " "+self.distribution.get_version(),
737 "DefaultDirName=" + self.default_dir_name,
738 "DefaultGroupName=" + self.default_group_name,
739 ])
740 if self.copyright:
741 iss.append("AppCopyright=" + self.copyright)
742 if self.license_file:
743 iss.append("LicenseFile=" + self.license_file)
744
745 iss.append("OutputBasefilename=" + self.output_basename)
746
747 iss.append("")
748 iss.append("[Files]")
749
750 install = self.get_finalized_command("install")
751 install_scripts = self.get_finalized_command("install_scripts")
752 script_files = install_scripts.get_outputs()
753 prefixlen = len(self.bdist_dir) + len(os.sep)
754 for filename in install.get_outputs():
755 filename = filename[prefixlen:]
756 icon = icons.get(filename)
757 dirname = os.path.dirname(filename)
758 if os.name != "nt":
759 # change the separators to \ on non-windos systems
760 filename = string.join(string.split(filename, os.sep), "\\")
761 dirname = string.join(string.split(dirname, os.sep), "\\")
762 line = 'Source: "%s"' % filename
763 if icon is not None:
764 # install it as defined in the icon object
765 backslash = string.rfind(icon.install_name, "\\")
766 if backslash >= 0:
767 dirname = icon.install_name[:backslash]
768 basename = icon.install_name[backslash + 1:]
769 else:
770 dirname = ""
771 basename = icon.install_name
772 line = '%s; DestDir: "%s"; DestName: "%s"' % (line, dirname,
773 basename)
774 else:
775 line = line + '; DestDir: "{app}\\%s"' % (dirname)
776 iss.append(line)
777
778 iss.append("")
779 iss.append("[Icons]")
780 for icon in self.icons_entries:
781 line = 'Name: "{group}\\%s"; Filename: "%s";' \
782 % (icon.title, icon.install_name)
783 iss.append(line)
784
785 return iss
786
787
788 class InnoIconItem:
789
790 """Describe one item for the start menu for the Inno Setup installer"""
791
792 def __init__(self, filename, title, install_name = None):
793 self.filename = filename
794 self.title = title
795 if install_name is not None:
796 self.install_name = install_name
797 else:
798 self.install_name = filename
799
800
801 class thuban_bdist_inno(bdist_inno):
802
803 """Thuban specific Inno Setup stuff"""
804
805 def run(self):
806 install_options = {
807 "prefix": ".",
808 "install_scripts": "$base",
809 "warn_dir": 0,
810 "extra_files": ["COPYING", "Lib/proj.dll"],
811 }
812 # don't make a symlink because we're simulating windows, so
813 # that we can generate the iss-file even on Linux
814 install_options["do_symlink"] = 0
815 bdist_inno.run(self, install_options)
816
817
818 #
819 # Run the script
820 #
821
822
823 long_description = """\
824 Thuban is a viewer for geographic data written in Python
825 """
826
827 setup(name = "Thuban",
828 version = "0.1.2",
829 description = "Geographic data viewer",
830 long_description = long_description,
831 licence = "GPL",
832 author = "Intevation GmbH",
833 author_email = "[email protected]",
834 url = "ftp:intevation.de/",
835
836 scripts = ["thuban.py"],
837 packages = ["Thuban", "Thuban.Lib", "Thuban.Model", "Thuban.UI"],
838 ext_modules = extensions,
839 py_modules = py_modules,
840 data_files = data_files,
841
842 # defaults for the install command
843 options = {"install":
844 # prefix defaults to python's prefix normally
845 {"prefix": prefix,
846 # make sure both libs and scripts are installed in the
847 # same directory.
848 "install_lib": "$base/thuban",
849 "install_scripts": "$base/thuban",
850 "install_data": "$base/thuban",
851
852 # Don't print warning messages about the lib dir not
853 # being on Python's path. The libraries are Thuban
854 # specific and are installed just for Thuban. They'll
855 # be automatically on Python's path when Thuban is run
856 "warn_dir": 0,
857 },
858 "bdist_inno":
859 {"icons_entries": [InnoIconItem(".\\thuban.py",
860 "Start Thuban",
861 "{app}\\thuban.pyw")],
862 "license_file": "COPYING",
863 }
864 },
865 cmdclass = {"build_py": thuban_build_py,
866 "install_local": InstallLocal,
867 "install": ThubanInstall,
868 "bdist_rpm": thuban_bdist_rpm,
869 "bdist_inno": thuban_bdist_inno,
870 "data_dist": data_dist
871 })
872
873

Properties

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26