/[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 18 by bh, Mon Sep 3 16:25:09 2001 UTC revision 671 by bh, Tue Apr 15 18:09:47 2003 UTC
# Line 1  Line 1 
1  # Copyright (c) 2001 by Intevation GmbH  # Copyright (c) 2001, 2002, 2003 by Intevation GmbH
2  # Authors:  # Authors:
3  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
4  #  #
# Line 17  __version__ = "$Revision$" Line 17  __version__ = "$Revision$"
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  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
24    from distutils.command.bdist_rpm import bdist_rpm
25  from distutils.file_util import write_file  from distutils.file_util import write_file
26    from distutils.filelist import FileList
27  from distutils.util import convert_path, change_root  from distutils.util import convert_path, change_root
28    
29    from distutils import archive_util, dir_util
30  import distutils  import distutils
31    
32  from string import split  from string import split
# Line 40  if os.name == "posix": Line 44  if os.name == "posix":
44      proj4_lib = "proj"      proj4_lib = "proj"
45    
46    
47      # You shpuldn't have to modify anything below here      # You shouldn't have to modify anything below here
48      ###################################################################      ###################################################################
49            
50      # The installation prefix (similar to autoconf's --prefix). This is      # The installation prefix (similar to autoconf's --prefix). This is
51      # only the default value, you can override it on the command line      # only the default value, you can override it on the command line
52      # with the install command's --prefix option      # with the install command's --prefix option.
53        #
54        # Note that there's a separate prefix option for the bdist_rpm
55        # command completely independend of this one.
56      prefix = "/usr/local/"      prefix = "/usr/local/"
57    
58        # Whether to create the thubaninit module. You can override this
59        # value on the commandline with the --create-init-module to the
60        # install command.
61        create_init_module = 1
62    
63      # On POSIX-systems we run wxgtk-config to determine the C++-compiler      # On POSIX-systems we run wxgtk-config to determine the C++-compiler
64      # flags      # flags
65      wx_config_script = "wxgtk-config"      wx_config_script = "wx-config"
66      # These lists will be filled automatically below      # These lists will be filled automatically below
67      wx_defs = []      wx_defs = []
68      wx_incdirs = []      wx_incdirs = []
# Line 69  elif os.name == "nt": Line 81  elif os.name == "nt":
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            
# Line 83  elif os.name == "nt": Line 97  elif os.name == "nt":
97      # the command line with the install command's --prefix option      # the command line with the install command's --prefix option
98      prefix = r"install"      prefix = r"install"
99    
100        # Whether to create the thubaninit module. You can override this
101        # value on the commandline with the --create-init-module to the
102        # install command. By default we don't create it under NT because we
103        # most often run install only as part of bdist_inno where we can't
104        # really create because it needs information only known at install
105        # time.
106        create_init_module = 0
107    
108      # There doesn't seem to be an easy way to get at the wx compiler      # There doesn't seem to be an easy way to get at the wx compiler
109      # flags, so we define them here. These flags work for us with      # flags, so we define them here. These flags work for us with
110      # wxPython 2.3.1. They may have to be modified for other versions.      # wxPython 2.3.1. They may have to be modified for other versions.
# Line 108  elif os.name == "nt": Line 130  elif os.name == "nt":
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',
# Line 142  def run_script(cmdline): Line 165  def run_script(cmdline):
165    
166    
167  def run_wx_script(command):  def run_wx_script(command):
168      # first, determine the C++ preprocessor flags      # first, determine the C++ preprocessor flags Use --cflags here
169      flags = run_script(command + ' --cxxflags ')      # because it seems that older version don't have --cxxflags and
170        # newer ones return the same result for both
171        flags = run_script(command + ' --cflags ')
172      if flags is None:      if flags is None:
173          return 0          return 0
174      for flag in split(flags):      for flag in split(flags):
# Line 195  py_modules = [] Line 220  py_modules = []
220  #  #
221    
222  extensions.append(Extension("Lib.wxproj",  extensions.append(Extension("Lib.wxproj",
223                              [ext_dir + "/thuban/wxproj.cpp",                              [ext_dir + "/thuban/wxproj.cpp"],
224                               shp_dir + "/shpopen.c"],                              include_dirs = ([shp_dir, proj4_incdir,
225                              include_dirs = [shp_dir, proj4_incdir] +wx_incdirs,                                               ext_dir + "/pyshapelib/"]
226                                                + wx_incdirs),
227                              define_macros = wx_defs,                              define_macros = wx_defs,
228                              library_dirs = [proj4_libdir] + wx_libdirs,                              library_dirs = [proj4_libdir] + wx_libdirs,
229                              libraries = [proj4_lib] + wx_libs))                              libraries = [proj4_lib] + wx_libs))
# Line 208  extensions.append(Extension("Lib.wxproj" Line 234  extensions.append(Extension("Lib.wxproj"
234    
235  extensions.append(Extension("Lib.shapelibc",  extensions.append(Extension("Lib.shapelibc",
236                              [ext_dir + "/pyshapelib/shapelib_wrap.c",                              [ext_dir + "/pyshapelib/shapelib_wrap.c",
237                               shp_dir + "/shpopen.c"],                               shp_dir + "/shpopen.c",
238                                 shp_dir + "/shptree.c"],
239                                include_dirs = [shp_dir]))
240    extensions.append(Extension("Lib.shptree",
241                                [ext_dir + "/pyshapelib/shptreemodule.c"],
242                              include_dirs = [shp_dir]))                              include_dirs = [shp_dir]))
243  extensions.append(Extension("Lib.dbflibc",  extensions.append(Extension("Lib.dbflibc",
244                              [ext_dir + "/pyshapelib/dbflib_wrap.c",                              [ext_dir + "/pyshapelib/dbflib_wrap.c",
# Line 235  py_modules.append(ext_dir + "/pyprojecti Line 265  py_modules.append(ext_dir + "/pyprojecti
265  data_files = []  data_files = []
266    
267  # bitmaps  # bitmaps
268  dir = "Resources/Bitmaps"  for d, pattern in [("Resources/Bitmaps", "Resources/Bitmaps/*.xpm"),
269  bitmaps = []                     ("Resources/Locale", "Resources/Locale/*/LC_MESSAGES/*.mo")
270  for file in os.listdir(os.path.join("Resources", "Bitmaps")):                     ]:
271      if string.lower(file[-4:]) == ".xpm":      data_files.append((d, glob.glob(pattern)))
         bitmaps.append(dir + '/' +  file)  
 data_files.append((dir, bitmaps))  
272    
273  #  #
274  #       Command definitions  #       Command definitions
275  #  #
276  # So far distutils are only meant to distribute python extensions, not  # So far distutils are only meant to distribute python extensions, not
277  # complete applications, so we have to redefine a few commands  # complete applications, so we have to redefine a few commands
278    #
279    
280    
281    # Much of the data_dist command is directly copied from the distutils'
282    # sdist command
283    class data_dist(Command):
284    
285        description = "create a data distribution (tarball, zip file, etc.)"
286    
287        user_options = [
288            ('formats=', None,
289             "formats for source distribution (comma-separated list)"),
290            ('keep-temp', 'k',
291             "keep the distribution tree around after creating " +
292             "archive file(s)"),
293            ('dist-dir=', 'd',
294             "directory to put the source distribution archive(s) in "
295             "[default: dist]"),
296            ]
297    
298        boolean_options = ['keep-temp']
299    
300        def initialize_options (self):
301            self.formats = None
302            self.keep_temp = 0
303            self.dist_dir = None
304    
305        def finalize_options (self):
306            self.ensure_string_list('formats')
307            if self.formats is None:
308                self.formats = ["zip"]
309            bad_format = archive_util.check_archive_formats(self.formats)
310            if bad_format:
311                raise DistutilsOptionError, \
312                      "unknown archive format '%s'" % bad_format
313    
314            if self.dist_dir is None:
315                self.dist_dir = "dist"
316    
317    
318        def run(self):
319            # 'filelist' contains the list of files that will make up the
320            # manifest
321            self.filelist = FileList()
322            
323            # Do whatever it takes to get the list of files to process.
324            # File list is accumulated in 'self.filelist'.
325            self.get_file_list()
326    
327            # Otherwise, go ahead and create the source distribution tarball,
328            # or zipfile, or whatever.
329            self.make_distribution()
330    
331        def get_file_list(self):
332            """Figure out the list of files to include in the data
333            distribution, and put it in 'self.filelist'.
334            """
335            self.filelist.findall("Data")
336            self.filelist.include_pattern("*", anchor = 0)
337            self.filelist.exclude_pattern(r'/(RCS|CVS)/.*', is_regex=1)
338            self.filelist.sort()
339            self.filelist.remove_duplicates()
340    
341        def make_release_tree(self, base_dir, files):
342            """Create the directory tree that will become the source
343            distribution archive.  All directories implied by the filenames in
344            'files' are created under 'base_dir', and then we hard link or copy
345            (if hard linking is unavailable) those files into place.
346            Essentially, this duplicates the developer's source tree, but in a
347            directory named after the distribution, containing only the files
348            to be distributed.
349            """
350            # Create all the directories under 'base_dir' necessary to
351            # put 'files' there; the 'mkpath()' is just so we don't die
352            # if the manifest happens to be empty.
353            self.mkpath(base_dir)
354            dir_util.create_tree(base_dir, files,
355                                 verbose=self.verbose, dry_run=self.dry_run)
356    
357            # And walk over the list of files, either making a hard link (if
358            # os.link exists) to each one that doesn't already exist in its
359            # corresponding location under 'base_dir', or copying each file
360            # that's out-of-date in 'base_dir'.  (Usually, all files will be
361            # out-of-date, because by default we blow away 'base_dir' when
362            # we're done making the distribution archives.)
363        
364            if hasattr(os, 'link'):        # can make hard links on this system
365                link = 'hard'
366                msg = "making hard links in %s..." % base_dir
367            else:                           # nope, have to copy
368                link = None
369                msg = "copying files to %s..." % base_dir
370    
371            if not files:
372                self.warn("no files to distribute -- empty manifest?")
373            else:
374                self.announce(msg)
375            for file in files:
376                if not os.path.isfile(file):
377                    self.warn("'%s' not a regular file -- skipping" % file)
378                else:
379                    dest = os.path.join(base_dir, file)
380                    self.copy_file(file, dest, link=link)
381    
382    
383        def make_distribution (self):
384            """Create the source distribution(s).  First, we create the release
385            tree with 'make_release_tree()'; then, we create all required
386            archive files (according to 'self.formats') from the release tree.
387            Finally, we clean up by blowing away the release tree (unless
388            'self.keep_temp' is true).  The list of archive files created is
389            stored so it can be retrieved later by 'get_archive_files()'.
390            """
391            # Don't warn about missing meta-data here -- should be (and is!)
392            # done elsewhere.
393            base_dir = "Thuban-data-" + self.distribution.get_version()
394            base_name = os.path.join(self.dist_dir, base_dir)
395    
396            self.make_release_tree(base_dir, self.filelist.files)
397            archive_files = []              # remember names of files we create
398            for fmt in self.formats:
399                file = self.make_archive(base_name, fmt, base_dir=base_dir)
400                archive_files.append(file)
401    
402            self.archive_files = archive_files
403    
404            if not self.keep_temp:
405                dir_util.remove_tree(base_dir, self.verbose, self.dry_run)
406    
407    
408    
# Line 259  class InstallLocal(Command): Line 415  class InstallLocal(Command):
415      """      """
416    
417      description =\      description =\
418          "Create some symlink so you can run thubanfrom the source directory"          "Create some symlinks so you can run thuban from the source directory"
419    
420      user_options = [      user_options = [
421          ('skip-build', None, "skip the build steps"),          ('skip-build', None, "skip the build steps"),
422            ('create-init-module', None,
423             "Create the thubaninit.py module to ease use of Thuban as a library"),
424            ('dont-create-init-module', None,
425             "Do not create the thubaninit.py module"),
426          ]          ]
427    
428        boolean_options = ["create-init-module"]
429        negative_opt = {'dont-create-init-module' : 'create-init-module'}
430    
431    
432      def initialize_options (self):      def initialize_options (self):
433          self.extensions = None          self.extensions = None
434          self.build_dir = None          self.build_dir = None
435          self.skip_build = None          self.skip_build = None
436            self.create_init_module = None
437    
438      def finalize_options (self):      def finalize_options (self):
439          self.set_undefined_options("install",          self.set_undefined_options("install",
440                                     ("build_lib", "build_dir"),                                     ("build_lib", "build_dir"),
441                                     ('skip_build', 'skip_build'))                                     ('skip_build', 'skip_build'))
442          self.extensions = self.distribution.ext_modules          self.extensions = self.distribution.ext_modules
443            if self.create_init_module is None:
444                # by default we create the init module
445                self.create_init_module = 1
446    
447      def run(self):      def run(self):
448          # Make sure we have built everything we need first          # Make sure we have built everything we need first
# Line 283  class InstallLocal(Command): Line 451  class InstallLocal(Command):
451          # now do the work. Simply link or copy the Lib dir          # now do the work. Simply link or copy the Lib dir
452          libdir = os.path.join(self.build_dir, "Lib")          libdir = os.path.join(self.build_dir, "Lib")
453          if os.name == "posix":          if os.name == "posix":
454              # on posix, just lilnk the Lib dir              # on posix, just link the Lib dir
455              self.link_dir(libdir, "Lib")              self.link_dir(libdir, "Lib")
456          else:          else:
457              self.copy_tree(libdir, "Lib")              self.copy_tree(libdir, "Lib")
458    
459            # create the init module if desired
460            if self.create_init_module:
461                # create the init module
462                initfilename = "thubaninit.py"
463                contents = thubaninit_contents("")
464                self.execute(write_file, (initfilename, contents),
465                             "Create %s" % initfilename)
466    
467      def link_dir(self, src, dest):      def link_dir(self, src, dest):
468          """Create a symbolic link dest pointing to src"""          """Create a symbolic link dest pointing to src"""
469          if self.verbose:          if self.verbose:
# Line 314  class thuban_build_py(build_py): Line 490  class thuban_build_py(build_py):
490      distribution.      distribution.
491      """      """
492    
493        # FIXME: When Thuban can rely on Python 2.3 as the oldest supported
494        # Python release we don't need to override the run and
495        # find_all_modules methods anymore. distutils will allow both python
496        # modules and packages starting with 2.3.
497    
498      def run(self):      def run(self):
499          """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
500          that this allows both packages and modules to be in one          that this allows both packages and modules to be in one
# Line 365  class thuban_build_py(build_py): Line 546  class thuban_build_py(build_py):
546          return modules          return modules
547    
548    
549    thubaninit_contents_start = """
550    # This module was automatically generated by Thuban's install script
551    '''Import this module once per program (best place is probably the file
552    that ends up as your __main__ module) to be able to import Thuban
553    afterwards.
554    
555    Usage:
556    
557    import thubaninit
558    import Thuban
559    '''
560    import sys, os
561    """
562    
563    thubaninit_contents_thubaninitdir = """
564    sys.path.insert(0, %(thubandir)s)
565    """
566    thubaninit_contents_otherdirs = """
567    # Put the Lib dir into the path. The Lib dir contains some extra Python
568    # modules
569    import Thuban
570    thubandir = os.path.join(Thuban.__path__[0], '..')
571    dir = os.path.join(thubandir, "Lib")
572    if os.path.isdir(dir):
573        sys.path.insert(0, dir)
574    """
575    
576    def thubaninit_contents(thubandir):
577        """Return the contents of the the thubaninit file as a list of lines.
578    
579        The parameter thubandir is the parent directory where the Thuban/
580        package or the empty string if the thubaninit file itself will be
581        located in that direcory as well.
582        """
583        contents = thubaninit_contents_start
584        if thubandir:
585            thubandir = repr(thubandir)
586            contents += thubaninit_contents_thubaninitdir % locals()
587        contents += thubaninit_contents_otherdirs
588        return contents.split("\n")
589    
590    
591  class ThubanInstall(install):  class ThubanInstall(install):
592    
# Line 381  class ThubanInstall(install): Line 603  class ThubanInstall(install):
603                          "(default on posix systems and only relevant there)"),                          "(default on posix systems and only relevant there)"),
604    
605                           ("extra-files", None,                           ("extra-files", None,
606                            "List of filenames or (src, dest) pairs describing "                            "List of filenames or (src, dest) pairs describing"
607                            " extra files to install "                            " extra files to install "
608                            "(can only be set from witin setup.py"),                            "(can only be set from witin setup.py"),
609    
610                             ("create-init-module=", None,
611                              "If true, create a module in the site-packages"
612                              " directory that tweaks sys.path to let you easily"
613                              " import thuban modules from outside of thuban."),
614                             ("init-module-dir=", None,
615                              "Directory in which to create the init module."
616                              " Defaults to Python's site-packages directory."),
617                           ])                           ])
618    
619      boolean_options = install.boolean_options[:]      boolean_options = install.boolean_options[:]
620      boolean_options.append("do-symlink")      boolean_options.append("do-symlink")
621        boolean_options.append("create-init-module")
622    
623      def initialize_options(self):      def initialize_options(self):
624          self.do_symlink = None          self.do_symlink = None
625          self.extra_files = []          self.extra_files = []
626    
627            # initialize the create_init_module flag from the global
628            # determined at runtime
629            self.create_init_module = create_init_module
630            self.init_module_dir = None
631          install.initialize_options(self)          install.initialize_options(self)
632    
633      def finalize_options(self):      def finalize_options(self):
# Line 401  class ThubanInstall(install): Line 637  class ThubanInstall(install):
637              else:              else:
638                  self.do_symlink = 0                  self.do_symlink = 0
639          install.finalize_options(self)          install.finalize_options(self)
640            self.expand_with_pure_python_dirs(["init_module_dir"])
641    
642        def expand_with_pure_python_dirs(self, attrs):
643            """Expand the attributes with default values of base and platbase"""
644            # it seems that the values for "prefix" and "exec_prefix" in
645            # self.config_vars are the corresponding values used by the
646            # python interpreter, so we just assign these to "base" and
647            # "platbase".
648            config_vars = self.config_vars.copy()
649            config_vars["base"] = self.config_vars["prefix"]
650            config_vars["platbase"] = self.config_vars["exec_prefix"]
651            for attr in attrs:
652                val = getattr(self, attr)
653                if val is not None:
654                    if os.name == 'posix':
655                        val = os.path.expanduser(val)
656                    val = subst_vars(val, config_vars)
657                    setattr(self, attr, val)
658    
659        def select_scheme(self, scheme):
660            """Extend the inherited method to set init_module_dir"""
661            install.select_scheme(self, scheme)
662            # only set init_module_dir if it wasn't set by the user
663            if self.init_module_dir is None:
664                self.init_module_dir = INSTALL_SCHEMES[scheme]['purelib']
665    
666        def convert_paths(self, *args):
667            """Extend the inherited method so that we can remember some filename
668            """
669            # remember the installation directory before its root gets
670            # changed
671            self.install_lib_orig = self.install_lib
672            apply(install.convert_paths, (self,) + args)
673    
674      def run(self):      def run(self):
675          install.run(self)          install.run(self)
# Line 409  class ThubanInstall(install): Line 678  class ThubanInstall(install):
678                  src, dest = item                  src, dest = item
679              else:              else:
680                  src = dest = item                  src = dest = item
681              self.copy_file(convert_path(src),              self.copy_file(convert_path(src),
682                             os.path.join(self.root, convert_path(dest)))                             os.path.join(self.root, convert_path(dest)))
683    
684          if os.name == "posix" and self.do_symlink:          if os.name == "posix" and self.do_symlink:
685              scriptfile = os.path.join(self.install_scripts, "thuban.py")              install_scripts = self.install_scripts
686                if self.root:
687                    install_scripts = install_scripts[len(self.root):]
688                scriptfile = os.path.join(install_scripts, "thuban.py")
689              bindir = os.path.join(self.prefix, "bin")              bindir = os.path.join(self.prefix, "bin")
690              if self.root:              if self.root:
691                  bindir = change_root(self.root, bindir)                  bindir = change_root(self.root, bindir)
692              binfile = os.path.join(bindir, "thuban")              binfile = os.path.join(bindir, "thuban")
693              self.mkpath(bindir)              self.mkpath(bindir)
694              self.copy_file(scriptfile, binfile, link="sym")              self.link_file(scriptfile, binfile)
695    
696            if self.create_init_module:
697                # create the init module
698                initfilename = self.thuban_init_filename()
699                if self.root:
700                    initfilename = change_root(self.root, initfilename)
701                contents = thubaninit_contents(self.install_lib_orig)
702                self.mkpath(os.path.dirname(initfilename))
703                self.execute(write_file, (initfilename, contents),
704                             "Create %s" % initfilename)
705    
706        def link_file(self, src, dest):
707            """Create a symbolic link dest pointing to src.
708    
709            Unlike the symlink variant of the command object's copy_file
710            method, this method even performs the link if src doesn't exist.
711            This is useful when installing with an alternat root directory"""
712            if self.verbose:
713                self.announce("symlinking %s -> %s" % (src, dest))
714            if self.dry_run:
715                return
716    
717            if not os.path.exists(dest):
718                os.symlink(src, dest)
719    
720        def thuban_init_filename(self):
721            """Return the filename for the init-module"""
722            # Since we override the normal install dirs to point to our own
723            # prefix we have to reach into installed
724            return self.init_module_dir + "/thubaninit.py"
725    
726      def get_outputs (self):      def get_outputs (self):
727          outputs = install.get_outputs(self)          outputs = install.get_outputs(self)
# Line 429  class ThubanInstall(install): Line 731  class ThubanInstall(install):
731              else:              else:
732                  src = dest = item                  src = dest = item
733              outputs.append(os.path.join(self.root, convert_path(dest)))              outputs.append(os.path.join(self.root, convert_path(dest)))
734            if os.name == "posix" and self.do_symlink:
735                bindir = os.path.join(self.prefix, "bin")
736                if self.root:
737                    bindir = change_root(self.root, bindir)
738                binfile = os.path.join(bindir, "thuban")
739                outputs.append(binfile)
740            if self.create_init_module:
741                initfilename = self.thuban_init_filename()
742                if self.root:
743                    initfilename = change_root(self.root, initfilename)
744                outputs.append(initfilename)
745          return outputs          return outputs
746    
747    
748    # scripts to override some of the commands put into the spec-file by the
749    # bdist_rpm command.
750    
751    bdist_rpm_prep_script = '''
752    %setup
753    cp extensions/pyshapelib/{README,README.pyshapelib}
754    cp extensions/pyshapelib/{COPYING,COPYING.pyshapelib}
755    cp extensions/pyprojection/{LICENSE,LICENSE.pyprojection}
756    '''
757    
758    bdist_rpm_build_script = '''
759    env PATH="$PATH:%(prefix)s/lib/wxPython/bin:/usr/lib/wxPython/bin" CFLAGS="$RPM_OPT_FLAGS" %(python)s setup.py build
760    '''
761    
762    bdist_rpm_install_script = '''
763    %(python)s setup.py install --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES \
764       --prefix=%(prefix)s
765    '''
766    
767    
768    class thuban_bdist_rpm(bdist_rpm):
769    
770        """Thuban specific RPM distribution command"""
771    
772        user_options = bdist_rpm.user_options[:]
773        user_options.extend([("prefix=", None, "Install prefix for the RPM"),
774                             ])
775    
776        def initialize_options(self):
777            # per default, RPMs are installed in /usr
778            self.prefix = "/usr/"
779    
780            # create the scripts we want to override. We actually fill them
781            # with contents later because some values we put into those
782            # scripts such as the python interpreter to use are only known
783            # then.
784            open("bdist_rpm_prep", "w").close()
785            open("bdist_rpm_build", "w").close()
786            open("bdist_rpm_install", "w").close()
787            bdist_rpm.initialize_options(self)
788    
789        def _make_spec_file(self):
790            # create the scripts for the spec-file. Now we know the python
791            # interpreter to use.
792            open("bdist_rpm_prep", "w").write(bdist_rpm_prep_script)
793    
794            build = bdist_rpm_build_script % {"python": self.python,
795                                              "prefix": self.prefix}
796            open("bdist_rpm_build", "w").write(build)
797    
798            install = bdist_rpm_install_script % {"python": self.python,
799                                                  "prefix": self.prefix}
800            open("bdist_rpm_install", "w").write(install)
801    
802            #
803            return bdist_rpm._make_spec_file(self)
804    
805    
806  class bdist_inno(Command):  class bdist_inno(Command):
807    
808      """Command to create a windows installer with Inno Setup"""      """Command to create a windows installer with Inno Setup"""
# Line 510  class bdist_inno(Command): Line 882  class bdist_inno(Command):
882          """Execute the command. install_options if given, should be a          """Execute the command. install_options if given, should be a
883          directory of additional options to set in the install step"""          directory of additional options to set in the install step"""
884          # Obviously have to build before we can install          # Obviously have to build before we can install
885    
886          if not self.skip_build:          if not self.skip_build:
887              self.run_command('build')              self.run_command('build')
888    
# Line 522  class bdist_inno(Command): Line 895  class bdist_inno(Command):
895          if os.name != 'nt':          if os.name != 'nt':
896              # Must force install to use the 'nt' scheme;              # Must force install to use the 'nt' scheme;
897              install.select_scheme('nt')              install.select_scheme('nt')
             # don't make a symlink because we're simulating windows, so  
             # that we can generate the iss-file even on Linux  
             install.do_symlink = 0  
898    
899          self.announce("installing to %s" % self.bdist_dir)          self.announce("installing to %s" % self.bdist_dir)
900          install.ensure_finalized()          install.ensure_finalized()
# Line 535  class bdist_inno(Command): Line 905  class bdist_inno(Command):
905          self.execute(write_file, (iss_file, self.generate_iss()),          self.execute(write_file, (iss_file, self.generate_iss()),
906                       "Create Inno Setup script file %s" % iss_file)                       "Create Inno Setup script file %s" % iss_file)
907    
908          # and invoke          # and invoke
909          if self.run_inno:          if self.run_inno:
910              self.spawn(["iscc", iss_file])              self.spawn(["iscc", iss_file])
911    
# Line 601  class bdist_inno(Command): Line 971  class bdist_inno(Command):
971              line = 'Name: "{group}\\%s"; Filename: "%s";' \              line = 'Name: "{group}\\%s"; Filename: "%s";' \
972                     % (icon.title, icon.install_name)                     % (icon.title, icon.install_name)
973              iss.append(line)              iss.append(line)
974                
975          return iss          return iss
976    
977    
978  class InnoIconItem:  class InnoIconItem:
979    
980      """Describe one item for he start menu for the Inno Setup installer"""      """Describe one item for the start menu for the Inno Setup installer"""
981    
982      def __init__(self, filename, title, install_name = None):      def __init__(self, filename, title, install_name = None):
983          self.filename = filename          self.filename = filename
# Line 625  class thuban_bdist_inno(bdist_inno): Line 995  class thuban_bdist_inno(bdist_inno):
995      def run(self):      def run(self):
996          install_options = {          install_options = {
997              "prefix": ".",              "prefix": ".",
998                "install_lib": "$base",
999                "install_data": "$base",
1000              "install_scripts": "$base",              "install_scripts": "$base",
1001              "warn_dir": 0,              "warn_dir": 0,
1002              "extra_files": ["COPYING", "Lib/proj.dll"],              "extra_files": ["COPYING", "Lib/proj.dll"],
1003              }              }
1004            # don't make a symlink because we're simulating windows, so
1005            # that we can generate the iss-file even on Linux
1006            install_options["do_symlink"] = 0
1007    
1008          bdist_inno.run(self, install_options)          bdist_inno.run(self, install_options)
1009        
1010                class thuban_build_docs(Command):
1011    
1012        """Command to generate documentation from source code."""
1013    
1014        description = "Generate documentation."
1015    
1016        user_options = []
1017    
1018        def initialize_options(self): pass
1019    
1020        def finalize_options(self): pass
1021    
1022        def run(self, install_options = None):
1023            self.spawn(["happydoc", "-d./Doc", "./Thuban"])
1024    
1025  #  #
1026  #   Run the script  #   Run the script
1027  #  #
# Line 642  Thuban is a viewer for geographic data w Line 1032  Thuban is a viewer for geographic data w
1032  """  """
1033    
1034  setup(name = "Thuban",  setup(name = "Thuban",
1035        version = "0.0.3",        version = "0.2.0",
1036        description = "Geographic data viewer",        description = "Geographic data viewer",
1037        long_description = long_description,        long_description = long_description,
1038        licence = "GPL",        licence = "GPL",
1039        author = "Intevation GmbH",        author = "Intevation GmbH",
1040        author_email = "[email protected]",        author_email = "[email protected]",
1041        url = "ftp:intevation.de/",        url = "http://thuban.intevation.de/",
1042    
1043        scripts = ["thuban.py"],        scripts = ["thuban.py"],
1044        packages = ["Thuban", "Thuban.Lib", "Thuban.Model", "Thuban.UI"],        packages = ["Thuban", "Thuban.Lib", "Thuban.Model", "Thuban.UI"],
# Line 662  setup(name = "Thuban", Line 1052  setup(name = "Thuban",
1052                   {"prefix": prefix,                   {"prefix": prefix,
1053                    # make sure both libs and scripts are installed in the                    # make sure both libs and scripts are installed in the
1054                    # same directory.                    # same directory.
1055                    "install_lib": "$base/thuban",                    "install_lib": "$base/lib/thuban",
1056                    "install_scripts": "$base/thuban",                    "install_scripts": "$base/lib/thuban",
1057                    "install_data": "$base/thuban",                    "install_data": "$base/lib/thuban",
1058    
1059                    # Don't print warning messages about the lib dir not                    # Don't print warning messages about the lib dir not
1060                    # being on Python's path. The libraries are Thuban                    # being on Python's path. The libraries are Thuban
# Line 682  setup(name = "Thuban", Line 1072  setup(name = "Thuban",
1072        cmdclass = {"build_py": thuban_build_py,        cmdclass = {"build_py": thuban_build_py,
1073                    "install_local": InstallLocal,                    "install_local": InstallLocal,
1074                    "install": ThubanInstall,                    "install": ThubanInstall,
1075                    "bdist_inno": thuban_bdist_inno                    "bdist_rpm": thuban_bdist_rpm,
1076                      "bdist_inno": thuban_bdist_inno,
1077                      "data_dist": data_dist,
1078                      "build_docs": thuban_build_docs
1079                    })                    })
1080    
1081    

Legend:
Removed from v.18  
changed lines
  Added in v.671

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26