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

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

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

revision 6 by bh, Tue Aug 28 15:41:52 2001 UTC revision 203 by bh, Mon Jul 8 15:04:57 2002 UTC
# Line 1  Line 1 
1  # Copyright (c) 2001 by Intevation GmbH  # Copyright (c) 2001, 2002 by Intevation GmbH
2  # Authors:  # Authors:
3  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
4  #  #
# Line 16  __version__ = "$Revision$" Line 16  __version__ = "$Revision$"
16  #  #
17    
18  import os  import os
19    from types import TupleType
20  from distutils.core import setup, Extension, Command  from distutils.core import setup, Extension, Command
21  from distutils.command.install import install  from distutils.command.install import install
22  from distutils.command.build_py import build_py  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  import distutils
 print distutils.__file__  
30    
31  from string import split  from string import split
32  import string  import string
# Line 43  if os.name == "posix": Line 48  if os.name == "posix":
48            
49      # The installation prefix (similar to autoconf's --prefix). This is      # The installation prefix (similar to autoconf's --prefix). This is
50      # only the default value, you can override it on the command line      # only the default value, you can override it on the command line
51      # with the install command's --prefix option      # with the install command's --prefix option.
52        #
53        # Note that there's a separate prefix option for the bdist_rpm
54        # command completely independend of this one.
55      prefix = "/usr/local/"      prefix = "/usr/local/"
56    
57      # On POSIX-systems we run wxgtk-config to determine the C++-compiler      # On POSIX-systems we run wxgtk-config to determine the C++-compiler
58      # flags      # flags
59      wx_config_script = "wxgtk-config"      wx_config_script = "wx-config"
60      # These lists will be filled automatically below      # These lists will be filled automatically below
61      wx_defs = []      wx_defs = []
62      wx_incdirs = []      wx_incdirs = []
# Line 66  elif os.name == "nt": Line 74  elif os.name == "nt":
74      proj4_libdir =  proj4_prefix      proj4_libdir =  proj4_prefix
75      proj4_lib = "proj_i"      proj4_lib = "proj_i"
76    
77        # Define include and lib directories for wxWindows and
78        wx_prefix = r"D:\wx230"
79        wx_inc =  os.path.join(wx_prefix, "include")
80        wx_lib =  os.path.join(wx_prefix, "lib")
81    
82      #      #
83      # Unless you use a wxPython version other than 2.3.1, you probably      # Unless you use a wxPython version other than 2.3.1, you probably
84      # shouldn't have to modify anything below here      # shouldn't have to modify anything below here
# Line 83  elif os.name == "nt": Line 96  elif os.name == "nt":
96      # there's no config script.      # there's no config script.
97      wx_config_script = ""      wx_config_script = ""
98            
     # so we just define the flags manually  
     wx_prefix = r"D:\wx230"  
     wx_inc =  os.path.join(wx_prefix, "include")  
     wx_lib =  os.path.join(wx_prefix, "lib")  
99      # the values of wx_defs and wx_libs. copied from the wxPython      # the values of wx_defs and wx_libs. copied from the wxPython
100      # setup.py      # setup.py
101      wx_defs = [ ('WIN32', None),        # Some of these are no longer      wx_defs = [ ('WIN32', None),        # Some of these are no longer
# Line 139  def run_script(cmdline): Line 148  def run_script(cmdline):
148    
149    
150  def run_wx_script(command):  def run_wx_script(command):
151      # first, determine the C++ preprocessor flags      # first, determine the C++ preprocessor flags Use --cflags here
152      flags = run_script(command + ' --cxxflags ')      # because it seems that older version don't have --cxxflags and
153        # newer ones return the same result for both
154        flags = run_script(command + ' --cflags ')
155      if flags is None:      if flags is None:
156          return 0          return 0
157      for flag in split(flags):      for flag in split(flags):
# Line 192  py_modules = [] Line 203  py_modules = []
203  #  #
204    
205  extensions.append(Extension("Lib.wxproj",  extensions.append(Extension("Lib.wxproj",
206                              [ext_dir + "/thuban/wxproj.cpp",                              [ext_dir + "/thuban/wxproj.cpp"],
207                               shp_dir + "/shpopen.c"],                              include_dirs = ([shp_dir, proj4_incdir,
208                              include_dirs = [shp_dir, proj4_incdir] +wx_incdirs,                                               ext_dir + "/pyshapelib/"]
209                                                + wx_incdirs),
210                              define_macros = wx_defs,                              define_macros = wx_defs,
211                              library_dirs = [proj4_libdir] + wx_libdirs,                              library_dirs = [proj4_libdir] + wx_libdirs,
212                              libraries = [proj4_lib] + wx_libs))                              libraries = [proj4_lib] + wx_libs))
# Line 205  extensions.append(Extension("Lib.wxproj" Line 217  extensions.append(Extension("Lib.wxproj"
217    
218  extensions.append(Extension("Lib.shapelibc",  extensions.append(Extension("Lib.shapelibc",
219                              [ext_dir + "/pyshapelib/shapelib_wrap.c",                              [ext_dir + "/pyshapelib/shapelib_wrap.c",
220                               shp_dir + "/shpopen.c"],                               shp_dir + "/shpopen.c",
221                                 shp_dir + "/shptree.c"],
222                                include_dirs = [shp_dir]))
223    extensions.append(Extension("Lib.shptree",
224                                [ext_dir + "/pyshapelib/shptreemodule.c"],
225                              include_dirs = [shp_dir]))                              include_dirs = [shp_dir]))
226  extensions.append(Extension("Lib.dbflibc",  extensions.append(Extension("Lib.dbflibc",
227                              [ext_dir + "/pyshapelib/dbflib_wrap.c",                              [ext_dir + "/pyshapelib/dbflib_wrap.c",
# Line 232  py_modules.append(ext_dir + "/pyprojecti Line 248  py_modules.append(ext_dir + "/pyprojecti
248  data_files = []  data_files = []
249    
250  # bitmaps  # bitmaps
251  dir = "Resources/Bitmaps/"  dir = "Resources/Bitmaps"
252  bitmaps = []  bitmaps = []
253  for file in os.listdir(os.path.join("Resources", "Bitmaps")):  for file in os.listdir(os.path.join("Resources", "Bitmaps")):
254      if string.lower(file[-4:]) == ".xpm":      if string.lower(file[-4:]) == ".xpm":
255          bitmaps.append(dir + file)          bitmaps.append(dir + '/' +  file)
256  data_files.append((dir, bitmaps))  data_files.append((dir, bitmaps))
257    
258  #  #
# Line 244  data_files.append((dir, bitmaps)) Line 260  data_files.append((dir, bitmaps))
260  #  #
261  # So far distutils are only meant to distribute python extensions, not  # So far distutils are only meant to distribute python extensions, not
262  # complete applications, so we have to redefine a few commands  # complete applications, so we have to redefine a few commands
263    #
264    
265    
266    # Much of the data_dist command is directly copied from the distutils'
267    # sdist command
268    class data_dist(Command):
269    
270        description = "create a data distribution (tarball, zip file, etc.)"
271    
272        user_options = [
273            ('formats=', None,
274             "formats for source distribution (comma-separated list)"),
275            ('keep-temp', 'k',
276             "keep the distribution tree around after creating " +
277             "archive file(s)"),
278            ('dist-dir=', 'd',
279             "directory to put the source distribution archive(s) in "
280             "[default: dist]"),
281            ]
282    
283        boolean_options = ['keep-temp']
284    
285        def initialize_options (self):
286            self.formats = None
287            self.keep_temp = 0
288            self.dist_dir = None
289    
290        def finalize_options (self):
291            self.ensure_string_list('formats')
292            if self.formats is None:
293                self.formats = ["zip"]
294            bad_format = archive_util.check_archive_formats(self.formats)
295            if bad_format:
296                raise DistutilsOptionError, \
297                      "unknown archive format '%s'" % bad_format
298    
299            if self.dist_dir is None:
300                self.dist_dir = "dist"
301    
302    
303        def run(self):
304            # 'filelist' contains the list of files that will make up the
305            # manifest
306            self.filelist = FileList()
307            
308            # Do whatever it takes to get the list of files to process.
309            # File list is accumulated in 'self.filelist'.
310            self.get_file_list()
311    
312            # Otherwise, go ahead and create the source distribution tarball,
313            # or zipfile, or whatever.
314            self.make_distribution()
315    
316        def get_file_list(self):
317            """Figure out the list of files to include in the data
318            distribution, and put it in 'self.filelist'.
319            """
320            self.filelist.findall("Data")
321            self.filelist.include_pattern("*", anchor = 0)
322            self.filelist.exclude_pattern(r'/(RCS|CVS)/.*', is_regex=1)
323            self.filelist.sort()
324            self.filelist.remove_duplicates()
325    
326        def make_release_tree(self, base_dir, files):
327            """Create the directory tree that will become the source
328            distribution archive.  All directories implied by the filenames in
329            'files' are created under 'base_dir', and then we hard link or copy
330            (if hard linking is unavailable) those files into place.
331            Essentially, this duplicates the developer's source tree, but in a
332            directory named after the distribution, containing only the files
333            to be distributed.
334            """
335            # Create all the directories under 'base_dir' necessary to
336            # put 'files' there; the 'mkpath()' is just so we don't die
337            # if the manifest happens to be empty.
338            self.mkpath(base_dir)
339            dir_util.create_tree(base_dir, files,
340                                 verbose=self.verbose, dry_run=self.dry_run)
341    
342            # And walk over the list of files, either making a hard link (if
343            # os.link exists) to each one that doesn't already exist in its
344            # corresponding location under 'base_dir', or copying each file
345            # that's out-of-date in 'base_dir'.  (Usually, all files will be
346            # out-of-date, because by default we blow away 'base_dir' when
347            # we're done making the distribution archives.)
348        
349            if hasattr(os, 'link'):        # can make hard links on this system
350                link = 'hard'
351                msg = "making hard links in %s..." % base_dir
352            else:                           # nope, have to copy
353                link = None
354                msg = "copying files to %s..." % base_dir
355    
356            if not files:
357                self.warn("no files to distribute -- empty manifest?")
358            else:
359                self.announce(msg)
360            for file in files:
361                if not os.path.isfile(file):
362                    self.warn("'%s' not a regular file -- skipping" % file)
363                else:
364                    dest = os.path.join(base_dir, file)
365                    self.copy_file(file, dest, link=link)
366    
367    
368        def make_distribution (self):
369            """Create the source distribution(s).  First, we create the release
370            tree with 'make_release_tree()'; then, we create all required
371            archive files (according to 'self.formats') from the release tree.
372            Finally, we clean up by blowing away the release tree (unless
373            'self.keep_temp' is true).  The list of archive files created is
374            stored so it can be retrieved later by 'get_archive_files()'.
375            """
376            # Don't warn about missing meta-data here -- should be (and is!)
377            # done elsewhere.
378            base_dir = "Thuban-data-" + self.distribution.get_version()
379            base_name = os.path.join(self.dist_dir, base_dir)
380    
381            self.make_release_tree(base_dir, self.filelist.files)
382            archive_files = []              # remember names of files we create
383            for fmt in self.formats:
384                file = self.make_archive(base_name, fmt, base_dir=base_dir)
385                archive_files.append(file)
386    
387            self.archive_files = archive_files
388    
389            if not self.keep_temp:
390                dir_util.remove_tree(base_dir, self.verbose, self.dry_run)
391    
392    
393    
# Line 256  class InstallLocal(Command): Line 400  class InstallLocal(Command):
400      """      """
401    
402      description =\      description =\
403          "Create some symlink so you can run thubanfrom the source directory"          "Create some symlinks so you can run thuban from the source directory"
404    
405      user_options = [      user_options = [
         ('debug', 'g', "compile/link with debugging information"),  
406          ('skip-build', None, "skip the build steps"),          ('skip-build', None, "skip the build steps"),
407          ]          ]
408    
# Line 267  class InstallLocal(Command): Line 410  class InstallLocal(Command):
410          self.extensions = None          self.extensions = None
411          self.build_dir = None          self.build_dir = None
412          self.skip_build = None          self.skip_build = None
         self.debug = None  
413    
414      def finalize_options (self):      def finalize_options (self):
415          self.set_undefined_options("install",          self.set_undefined_options("install",
# Line 282  class InstallLocal(Command): Line 424  class InstallLocal(Command):
424          # now do the work. Simply link or copy the Lib dir          # now do the work. Simply link or copy the Lib dir
425          libdir = os.path.join(self.build_dir, "Lib")          libdir = os.path.join(self.build_dir, "Lib")
426          if os.name == "posix":          if os.name == "posix":
427              # on posix, just lilnk the Lib dir              # on posix, just link the Lib dir
428              self.link_dir(libdir, "Lib")              self.link_dir(libdir, "Lib")
429          else:          else:
430              self.copy_tree(libdir, "Lib")              self.copy_tree(libdir, "Lib")
# Line 290  class InstallLocal(Command): Line 432  class InstallLocal(Command):
432      def link_dir(self, src, dest):      def link_dir(self, src, dest):
433          """Create a symbolic link dest pointing to src"""          """Create a symbolic link dest pointing to src"""
434          if self.verbose:          if self.verbose:
435              print "symlinking %s -> %s" % (src, dest)              self.announce("symlinking %s -> %s" % (src, dest))
436          if self.dry_run:          if self.dry_run:
437              return              return
438    
# Line 309  class InstallLocal(Command): Line 451  class InstallLocal(Command):
451  class thuban_build_py(build_py):  class thuban_build_py(build_py):
452    
453      """      """
454      A new build_py that can deal with both packages and modules in      A new build_py that can deal with both packages and modules in one
455      one distribution.      distribution.
456      """      """
457    
458      def run(self):      def run(self):
459          """The same the as teh original in build_py revision 1.33 except          """The same the as the original in build_py revision 1.33 except
460          that this allows both packages and modules to be in one          that this allows both packages and modules to be in one
461          distribution          distribution
462          """          """
# Line 348  class thuban_build_py(build_py): Line 490  class thuban_build_py(build_py):
490              modules.append(("Lib", module_base, module_file))              modules.append(("Lib", module_base, module_file))
491          return modules          return modules
492    
493  #      def find_all_modules (self):
494  # Extend the standard install command to symlink the installed script to          # same as find_all_modules of the original build_py command
495  # $prefix/bin/          # (rev. 1.33) but handle installations with both modules and
496  #          # packages. Needed here so tha the get_outputs works correctly
497            modules = []
498            if self.py_modules:
499                modules.extend(self.find_modules())
500            if self.packages:
501                for package in self.packages:
502                    package_dir = self.get_package_dir(package)
503                    m = self.find_package_modules(package, package_dir)
504                    modules.extend(m)
505    
506            return modules
507    
508    
509    
510  class ThubanInstall(install):  class ThubanInstall(install):
511    
512        """
513        Thuban specific install command.
514    
515        Extend the standard install command to symlink the installed script
516        to $prefix/bin/
517        """
518    
519        user_options = install.user_options[:]
520        user_options.extend([("do-symlink", None,
521                              "Create a symlink to the script in <prefix>/bin."
522                            "(default on posix systems and only relevant there)"),
523    
524                             ("extra-files", None,
525                              "List of filenames or (src, dest) pairs describing "
526                              " extra files to install "
527                              "(can only be set from witin setup.py"),
528                             ])
529    
530        boolean_options = install.boolean_options[:]
531        boolean_options.append("do-symlink")
532    
533        def initialize_options(self):
534            self.do_symlink = None
535            self.extra_files = []
536            install.initialize_options(self)
537    
538        def finalize_options(self):
539            if self.do_symlink is None:
540                if os.name == "posix":
541                    self.do_symlink = 1
542                else:
543                    self.do_symlink = 0
544            install.finalize_options(self)
545    
546      def run(self):      def run(self):
547          install.run(self)          install.run(self)
548          if os.name == "posix":          for item in self.extra_files:
549              scriptfile = os.path.join(self.install_scripts, "thuban.py")              if type(item) == TupleType:
550                    src, dest = item
551                else:
552                    src = dest = item
553                self.copy_file(convert_path(src),
554                               os.path.join(self.root, convert_path(dest)))
555    
556            if os.name == "posix" and self.do_symlink:
557                install_scripts = self.install_scripts
558                if self.root:
559                    install_scripts = install_scripts[len(self.root):]
560                scriptfile = os.path.join(install_scripts, "thuban.py")
561              bindir = os.path.join(self.prefix, "bin")              bindir = os.path.join(self.prefix, "bin")
562                if self.root:
563                    bindir = change_root(self.root, bindir)
564              binfile = os.path.join(bindir, "thuban")              binfile = os.path.join(bindir, "thuban")
565              self.mkpath(bindir)              self.mkpath(bindir)
566              self.copy_file(scriptfile, binfile, link="sym")              self.link_file(scriptfile, binfile)
567    
568        def link_file(self, src, dest):
569            """Create a symbolic link dest pointing to src.
570    
571            Unlike the symlink variant of the command object's copy_file
572            method, this method even performs the link if src doesn't exist.
573            This is useful when installing with an alternat root directory"""
574            if self.verbose:
575                self.announce("symlinking %s -> %s" % (src, dest))
576            if self.dry_run:
577                return
578    
579            if not os.path.exists(dest):
580                os.symlink(src, dest)
581    
582    
583        def get_outputs (self):
584            outputs = install.get_outputs(self)
585            for item in self.extra_files:
586                if type(item) == TupleType:
587                    src, dest = item
588                else:
589                    src = dest = item
590                outputs.append(os.path.join(self.root, convert_path(dest)))
591            if os.name == "posix" and self.do_symlink:
592                bindir = os.path.join(self.prefix, "bin")
593                if self.root:
594                    bindir = change_root(self.root, bindir)
595                binfile = os.path.join(bindir, "thuban")
596                outputs.append(binfile)
597            return outputs
598    
599    
600    # scripts to override some of the commands put into the spec-file by the
601    # bdist_rpm command.
602    
603    bdist_rpm_prep_script = '''
604    %setup
605    cp extensions/pyshapelib/{README,README.pyshapelib}
606    cp extensions/pyshapelib/{COPYING,COPYING.pyshapelib}
607    cp extensions/pyprojection/{LICENSE,LICENSE.pyprojection}
608    '''
609    
610    bdist_rpm_install_script = '''
611    %(python)s setup.py install --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES \
612       --prefix=%(prefix)s
613    '''
614    
615        
616    class thuban_bdist_rpm(bdist_rpm):
617    
618        """Thuban specific RPM distribution command"""
619    
620        user_options = bdist_rpm.user_options[:]
621        user_options.extend([("prefix=", None, "Install prefix for the RPM"),
622                             ])
623    
624        def initialize_options(self):
625            # per default, RPMs are installed in /usr
626            self.prefix = "/usr/"
627    
628            # create the scripts we want to override. We actually fill them
629            # with contents later because some values we put into those
630            # scripts such as the python interpreter to use are only known
631            # then.
632            open("bdist_rpm_prep", "w").close()
633            open("bdist_rpm_install", "w").close()
634            bdist_rpm.initialize_options(self)
635    
636        def _make_spec_file(self):
637            # create the scripts for the spec-file. Now we know the python
638            # interpreter to use.
639            open("bdist_rpm_prep", "w").write(bdist_rpm_prep_script)
640            install = bdist_rpm_install_script % {"python": self.python,
641                                                  "prefix": self.prefix}
642            open("bdist_rpm_install", "w").write(install)
643    
644            #
645            return bdist_rpm._make_spec_file(self)
646    
647    
648    class bdist_inno(Command):
649    
650        """Command to create a windows installer with Inno Setup"""
651    
652        description = "Create a windows installer with Inno Setup"
653    
654        user_options = [
655            ('skip-build', None, "skip the build steps"),
656            ('bdist-dir=', None,
657             "temporary directory for creating the distribution"),
658            ('run-inno', None,
659             "Run inno-setup to create the installer. On by default on nt"),
660            ('iss-name', None,
661             "The name of the iss file to generate. "
662             "Shouldn't contain directories"),
663    
664            # Parameters for the Inno Setup script
665            ('copyright', None, "Copyright notice for the Inno Setup file"),
666            ('default-dir-name', None,
667             "Default installation directory. Defaults to '{pf}\\<name>'"),
668            ('default-group-name', None,
669             "Default program group name. Defaults to <name>'"),
670            ("license-file", None, "File containing the license."),
671            ("output-basename", None,
672             "Base filename for the Inno Setup output "
673             "(defaults to <name>-<version>-<issrevision>)."),
674            ("iss-revision", None,
675             "revision of the generated installer of the package version"),
676    
677            ("icons-entries", None,
678             "List if InnoIconItems "
679             "(this can only be set from inside the setup.py script)"),
680            ]
681    
682        boolean_options = ["do-symlink"]
683    
684        def initialize_options(self):
685            self.skip_build = 0
686            self.bdist_dir = None
687            self.run_inno = None
688            self.iss_name = None
689            self.copyright = ""
690            self.default_dir_name = None
691            self.default_group_name = None
692            self.license_file = None
693            self.output_basename = None
694            self.iss_revision = None
695            self.icons_entries = []
696    
697        def finalize_options(self):
698            self.set_undefined_options("install",
699                                       ('skip_build', 'skip_build'))
700            if self.bdist_dir is None:
701                bdist_base = self.get_finalized_command('bdist').bdist_base
702                self.bdist_dir = os.path.join(bdist_base, 'inno')
703    
704            if self.run_inno is None:
705                self.run_inno = os.name == "nt"
706    
707            name = self.distribution.get_name()
708            if self.iss_name is None:
709                self.iss_name = name + '.iss'
710    
711            if self.default_dir_name is None:
712                self.default_dir_name = "{pf}\\" + name
713            if self.default_group_name is None:
714                self.default_group_name = name
715    
716            if self.iss_revision is None:
717                self.iss_revision = 0
718            if self.output_basename is None:
719                self.output_basename = "%s-%s-%d" \
720                                       % (name, self.distribution.get_version(),
721                                          self.iss_revision)
722    
723        def run(self, install_options = None):
724            """Execute the command. install_options if given, should be a
725            directory of additional options to set in the install step"""
726            # Obviously have to build before we can install
727            if not self.skip_build:
728                self.run_command('build')
729    
730            # Install in a temporary directory
731            install = self.reinitialize_command('install')
732            install.root = self.bdist_dir
733            if install_options is not None:
734                for key, value in install_options.items():
735                    setattr(install, key, value)
736            if os.name != 'nt':
737                # Must force install to use the 'nt' scheme;
738                install.select_scheme('nt')
739    
740            self.announce("installing to %s" % self.bdist_dir)
741            install.ensure_finalized()
742            install.run()
743    
744            # Create the iss file
745            iss_file = os.path.join(self.bdist_dir, self.iss_name)
746            self.execute(write_file, (iss_file, self.generate_iss()),
747                         "Create Inno Setup script file %s" % iss_file)
748    
749            # and invoke
750            if self.run_inno:
751                self.spawn(["iscc", iss_file])
752    
753        def generate_iss(self):
754            """Return the contents of the iss file as list of strings, one
755            string per line"""
756    
757            # first, turn the icons entries into a more usable form
758            icons = {}
759            for item in self.icons_entries:
760                icons[item.filename] = item
761    
762            iss = []
763    
764            name = self.distribution.get_name()
765            iss.extend(["[Setup]",
766                        "AppName=" + name,
767                        "AppVerName=" + name + " "+self.distribution.get_version(),
768                        "DefaultDirName=" + self.default_dir_name,
769                        "DefaultGroupName=" + self.default_group_name,
770                        ])
771            if self.copyright:
772                iss.append("AppCopyright=" + self.copyright)
773            if self.license_file:
774                iss.append("LicenseFile=" + self.license_file)
775    
776            iss.append("OutputBasefilename=" + self.output_basename)
777    
778            iss.append("")
779            iss.append("[Files]")
780    
781            install = self.get_finalized_command("install")
782            install_scripts = self.get_finalized_command("install_scripts")
783            script_files = install_scripts.get_outputs()
784            prefixlen = len(self.bdist_dir) + len(os.sep)
785            for filename in install.get_outputs():
786                filename = filename[prefixlen:]
787                icon = icons.get(filename)
788                dirname = os.path.dirname(filename)
789                if os.name != "nt":
790                    # change the separators to \ on non-windos systems
791                    filename = string.join(string.split(filename, os.sep), "\\")
792                    dirname =  string.join(string.split(dirname, os.sep), "\\")
793                line = 'Source: "%s"' % filename
794                if icon is not None:
795                    # install it as defined in the icon object
796                    backslash = string.rfind(icon.install_name, "\\")
797                    if backslash >= 0:
798                        dirname = icon.install_name[:backslash]
799                        basename = icon.install_name[backslash + 1:]
800                    else:
801                        dirname = ""
802                        basename = icon.install_name
803                    line = '%s; DestDir: "%s"; DestName: "%s"' % (line, dirname,
804                                                                  basename)
805                else:
806                    line = line + '; DestDir: "{app}\\%s"' % (dirname)
807                iss.append(line)
808    
809            iss.append("")
810            iss.append("[Icons]")
811            for icon in self.icons_entries:
812                line = 'Name: "{group}\\%s"; Filename: "%s";' \
813                       % (icon.title, icon.install_name)
814                iss.append(line)
815                
816            return iss
817    
818    
819    class InnoIconItem:
820    
821        """Describe one item for the start menu for the Inno Setup installer"""
822    
823        def __init__(self, filename, title, install_name = None):
824            self.filename = filename
825            self.title = title
826            if install_name is not None:
827                self.install_name = install_name
828            else:
829                self.install_name = filename
830    
831                
832    class thuban_bdist_inno(bdist_inno):
833    
834        """Thuban specific Inno Setup stuff"""
835    
836        def run(self):
837            install_options = {
838                "prefix": ".",
839                "install_scripts": "$base",
840                "warn_dir": 0,
841                "extra_files": ["COPYING", "Lib/proj.dll"],
842                }
843            # don't make a symlink because we're simulating windows, so
844            # that we can generate the iss-file even on Linux
845            install_options["do_symlink"] = 0
846            bdist_inno.run(self, install_options)
847        
848                
849    #
850    #   Run the script
851    #
852    
853    
854  long_description = """\  long_description = """\
855  Thuban is a viewer for geographic data written in Python  Thuban is a viewer for geographic data written in Python
856  """  """
857    
858  setup(name = "thuban",  setup(name = "Thuban",
859        version = "0.0.3",        version = "0.1.2",
860        description = "Geographic data viewer",        description = "Geographic data viewer",
861        long_description = long_description,        long_description = long_description,
862        licence = "GPL",        licence = "GPL",
# Line 390  setup(name = "thuban", Line 876  setup(name = "thuban",
876                   {"prefix": prefix,                   {"prefix": prefix,
877                    # make sure both libs and scripts are installed in the                    # make sure both libs and scripts are installed in the
878                    # same directory.                    # same directory.
879                    "install_lib": "$base/thuban",                    "install_lib": "$base/lib/thuban",
880                    "install_scripts": "$base/thuban",                    "install_scripts": "$base/lib/thuban",
881                    "install_data": "$base/thuban/",                    "install_data": "$base/lib/thuban",
882    
883                    # Don't print warning messages about the lib dir not                    # Don't print warning messages about the lib dir not
884                    # being on Python's path. The libraries are Thuban                    # being on Python's path. The libraries are Thuban
885                    # specific and are installed just for Thuban. They'll                    # specific and are installed just for Thuban. They'll
886                    # be automatically on Python's path when Thuban is run                    # be automatically on Python's path when Thuban is run
887                    "warn_dir": 0,                    "warn_dir": 0,
888                    }},                    },
889                     "bdist_inno":
890                     {"icons_entries": [InnoIconItem(".\\thuban.py",
891                                                     "Start Thuban",
892                                                     "{app}\\thuban.pyw")],
893                      "license_file": "COPYING",
894                      }
895                     },
896        cmdclass = {"build_py": thuban_build_py,        cmdclass = {"build_py": thuban_build_py,
897                    "install_local": InstallLocal,                    "install_local": InstallLocal,
898                    "install": ThubanInstall})                    "install": ThubanInstall,
899                      "bdist_rpm": thuban_bdist_rpm,
900                      "bdist_inno": thuban_bdist_inno,
901                      "data_dist": data_dist
902                      })
903    
904    

Legend:
Removed from v.6  
changed lines
  Added in v.203

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26