/[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 67 by bh, Thu Oct 18 14:50:21 2001 UTC
# Line 20  from types import TupleType Line 20  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  from distutils.file_util import write_file
25    from distutils.filelist import FileList
26  from distutils.util import convert_path, change_root  from distutils.util import convert_path, change_root
27    
28    from distutils import archive_util, dir_util
29  import distutils  import distutils
30    
31  from string import split  from string import split
# Line 50  if os.name == "posix": Line 53  if os.name == "posix":
53    
54      # On POSIX-systems we run wxgtk-config to determine the C++-compiler      # On POSIX-systems we run wxgtk-config to determine the C++-compiler
55      # flags      # flags
56      wx_config_script = "wxgtk-config"      wx_config_script = "wx-config"
57      # These lists will be filled automatically below      # These lists will be filled automatically below
58      wx_defs = []      wx_defs = []
59      wx_incdirs = []      wx_incdirs = []
# Line 142  def run_script(cmdline): Line 145  def run_script(cmdline):
145    
146    
147  def run_wx_script(command):  def run_wx_script(command):
148      # first, determine the C++ preprocessor flags      # first, determine the C++ preprocessor flags Use --cflags here
149      flags = run_script(command + ' --cxxflags ')      # 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:      if flags is None:
153          return 0          return 0
154      for flag in split(flags):      for flag in split(flags):
# Line 247  data_files.append((dir, bitmaps)) Line 252  data_files.append((dir, bitmaps))
252  #  #
253  # So far distutils are only meant to distribute python extensions, not  # So far distutils are only meant to distribute python extensions, not
254  # complete applications, so we have to redefine a few commands  # complete applications, so we have to redefine a few commands
255    #
256    
257    
258    # Much of the data_dist command is directly copied from the distutils'
259    # sdist command
260    class data_dist(Command):
261    
262        description = "create a data distribution (tarball, zip file, etc.)"
263    
264        user_options = [
265            ('formats=', None,
266             "formats for source distribution (comma-separated list)"),
267            ('keep-temp', 'k',
268             "keep the distribution tree around after creating " +
269             "archive file(s)"),
270            ('dist-dir=', 'd',
271             "directory to put the source distribution archive(s) in "
272             "[default: dist]"),
273            ]
274    
275        boolean_options = ['keep-temp']
276    
277        def initialize_options (self):
278            self.formats = None
279            self.keep_temp = 0
280            self.dist_dir = None
281    
282        def finalize_options (self):
283            self.ensure_string_list('formats')
284            if self.formats is None:
285                self.formats = ["zip"]
286            bad_format = archive_util.check_archive_formats(self.formats)
287            if bad_format:
288                raise DistutilsOptionError, \
289                      "unknown archive format '%s'" % bad_format
290    
291            if self.dist_dir is None:
292                self.dist_dir = "dist"
293    
294    
295        def run(self):
296            # 'filelist' contains the list of files that will make up the
297            # manifest
298            self.filelist = FileList()
299            
300            # Do whatever it takes to get the list of files to process.
301            # File list is accumulated in 'self.filelist'.
302            self.get_file_list()
303    
304            # Otherwise, go ahead and create the source distribution tarball,
305            # or zipfile, or whatever.
306            self.make_distribution()
307    
308        def get_file_list(self):
309            """Figure out the list of files to include in the data
310            distribution, and put it in 'self.filelist'.
311            """
312            self.filelist.findall("Data")
313            self.filelist.include_pattern("*", anchor = 0)
314            self.filelist.exclude_pattern(r'/(RCS|CVS)/.*', is_regex=1)
315            self.filelist.sort()
316            self.filelist.remove_duplicates()
317    
318        def make_release_tree(self, base_dir, files):
319            """Create the directory tree that will become the source
320            distribution archive.  All directories implied by the filenames in
321            'files' are created under 'base_dir', and then we hard link or copy
322            (if hard linking is unavailable) those files into place.
323            Essentially, this duplicates the developer's source tree, but in a
324            directory named after the distribution, containing only the files
325            to be distributed.
326            """
327            # Create all the directories under 'base_dir' necessary to
328            # put 'files' there; the 'mkpath()' is just so we don't die
329            # if the manifest happens to be empty.
330            self.mkpath(base_dir)
331            dir_util.create_tree(base_dir, files,
332                                 verbose=self.verbose, dry_run=self.dry_run)
333    
334            # And walk over the list of files, either making a hard link (if
335            # os.link exists) to each one that doesn't already exist in its
336            # corresponding location under 'base_dir', or copying each file
337            # that's out-of-date in 'base_dir'.  (Usually, all files will be
338            # out-of-date, because by default we blow away 'base_dir' when
339            # we're done making the distribution archives.)
340        
341            if hasattr(os, 'link'):        # can make hard links on this system
342                link = 'hard'
343                msg = "making hard links in %s..." % base_dir
344            else:                           # nope, have to copy
345                link = None
346                msg = "copying files to %s..." % base_dir
347    
348            if not files:
349                self.warn("no files to distribute -- empty manifest?")
350            else:
351                self.announce(msg)
352            for file in files:
353                if not os.path.isfile(file):
354                    self.warn("'%s' not a regular file -- skipping" % file)
355                else:
356                    dest = os.path.join(base_dir, file)
357                    self.copy_file(file, dest, link=link)
358    
359    
360        def make_distribution (self):
361            """Create the source distribution(s).  First, we create the release
362            tree with 'make_release_tree()'; then, we create all required
363            archive files (according to 'self.formats') from the release tree.
364            Finally, we clean up by blowing away the release tree (unless
365            'self.keep_temp' is true).  The list of archive files created is
366            stored so it can be retrieved later by 'get_archive_files()'.
367            """
368            # Don't warn about missing meta-data here -- should be (and is!)
369            # done elsewhere.
370            base_dir = "Thuban-data-" + self.distribution.get_version()
371            base_name = os.path.join(self.dist_dir, base_dir)
372    
373            self.make_release_tree(base_dir, self.filelist.files)
374            archive_files = []              # remember names of files we create
375            for fmt in self.formats:
376                file = self.make_archive(base_name, fmt, base_dir=base_dir)
377                archive_files.append(file)
378    
379            self.archive_files = archive_files
380    
381            if not self.keep_temp:
382                dir_util.remove_tree(base_dir, self.verbose, self.dry_run)
383    
384    
385    
# Line 413  class ThubanInstall(install): Line 546  class ThubanInstall(install):
546                             os.path.join(self.root, convert_path(dest)))                             os.path.join(self.root, convert_path(dest)))
547    
548          if os.name == "posix" and self.do_symlink:          if os.name == "posix" and self.do_symlink:
549              scriptfile = os.path.join(self.install_scripts, "thuban.py")              install_scripts = self.install_scripts
550                if self.root:
551                    install_scripts = install_scripts[len(self.root):]
552                scriptfile = os.path.join(install_scripts, "thuban.py")
553              bindir = os.path.join(self.prefix, "bin")              bindir = os.path.join(self.prefix, "bin")
554              if self.root:              if self.root:
555                  bindir = change_root(self.root, bindir)                  bindir = change_root(self.root, bindir)
556              binfile = os.path.join(bindir, "thuban")              binfile = os.path.join(bindir, "thuban")
557              self.mkpath(bindir)              self.mkpath(bindir)
558              self.copy_file(scriptfile, binfile, link="sym")              self.link_file(scriptfile, binfile)
559    
560        def link_file(self, src, dest):
561            """Create a symbolic link dest pointing to src.
562    
563            Unlike the symlink variant of the command object's copy_file
564            method, this method even performs the link if src doesn't exist.
565            This is useful when installing with an alternat root directory"""
566            if self.verbose:
567                self.announce("symlinking %s -> %s" % (src, dest))
568            if self.dry_run:
569                return
570    
571            if not os.path.exists(dest):
572                os.symlink(src, dest)
573    
574    
575      def get_outputs (self):      def get_outputs (self):
576          outputs = install.get_outputs(self)          outputs = install.get_outputs(self)
# Line 429  class ThubanInstall(install): Line 580  class ThubanInstall(install):
580              else:              else:
581                  src = dest = item                  src = dest = item
582              outputs.append(os.path.join(self.root, convert_path(dest)))              outputs.append(os.path.join(self.root, convert_path(dest)))
583            if os.name == "posix" and self.do_symlink:
584                bindir = os.path.join(self.prefix, "bin")
585                if self.root:
586                    bindir = change_root(self.root, bindir)
587                binfile = os.path.join(bindir, "thuban")
588                outputs.append(binfile)
589          return outputs          return outputs
590    
591    
592    bdist_rpm_prep_script = '''
593    %setup
594    cp extensions/pyshapelib/{README,README.pyshapelib}
595    cp extensions/pyshapelib/{COPYING,COPYING.pyshapelib}
596    cp extensions/pyprojection/{LICENSE,LICENSE.pyprojection}
597    '''
598    
599    
600        
601    class thuban_bdist_rpm(bdist_rpm):
602    
603        """Thuban specific RPM distribution command"""
604    
605        def run(self):
606            # create the prep script for the spec-file
607            open("bdist_rpm_prep", "w").write(bdist_rpm_prep_script)
608    
609            bdist_rpm.run(self)
610    
611    
612  class bdist_inno(Command):  class bdist_inno(Command):
613    
614      """Command to create a windows installer with Inno Setup"""      """Command to create a windows installer with Inno Setup"""
# Line 522  class bdist_inno(Command): Line 700  class bdist_inno(Command):
700          if os.name != 'nt':          if os.name != 'nt':
701              # Must force install to use the 'nt' scheme;              # Must force install to use the 'nt' scheme;
702              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  
703    
704          self.announce("installing to %s" % self.bdist_dir)          self.announce("installing to %s" % self.bdist_dir)
705          install.ensure_finalized()          install.ensure_finalized()
# Line 607  class bdist_inno(Command): Line 782  class bdist_inno(Command):
782    
783  class InnoIconItem:  class InnoIconItem:
784    
785      """Describe one item for he start menu for the Inno Setup installer"""      """Describe one item for the start menu for the Inno Setup installer"""
786    
787      def __init__(self, filename, title, install_name = None):      def __init__(self, filename, title, install_name = None):
788          self.filename = filename          self.filename = filename
# Line 617  class InnoIconItem: Line 792  class InnoIconItem:
792          else:          else:
793              self.install_name = filename              self.install_name = filename
794    
795                
796  class thuban_bdist_inno(bdist_inno):  class thuban_bdist_inno(bdist_inno):
797    
798      """Thuban specific Inno Setup stuff"""      """Thuban specific Inno Setup stuff"""
# Line 629  class thuban_bdist_inno(bdist_inno): Line 804  class thuban_bdist_inno(bdist_inno):
804              "warn_dir": 0,              "warn_dir": 0,
805              "extra_files": ["COPYING", "Lib/proj.dll"],              "extra_files": ["COPYING", "Lib/proj.dll"],
806              }              }
807            # don't make a symlink because we're simulating windows, so
808            # that we can generate the iss-file even on Linux
809            install_options["do_symlink"] = 0
810          bdist_inno.run(self, install_options)          bdist_inno.run(self, install_options)
811            
812                            
# Line 642  Thuban is a viewer for geographic data w Line 820  Thuban is a viewer for geographic data w
820  """  """
821    
822  setup(name = "Thuban",  setup(name = "Thuban",
823        version = "0.0.3",        version = "0.1",
824        description = "Geographic data viewer",        description = "Geographic data viewer",
825        long_description = long_description,        long_description = long_description,
826        licence = "GPL",        licence = "GPL",
# Line 682  setup(name = "Thuban", Line 860  setup(name = "Thuban",
860        cmdclass = {"build_py": thuban_build_py,        cmdclass = {"build_py": thuban_build_py,
861                    "install_local": InstallLocal,                    "install_local": InstallLocal,
862                    "install": ThubanInstall,                    "install": ThubanInstall,
863                    "bdist_inno": thuban_bdist_inno                    "bdist_rpm": thuban_bdist_rpm,
864                      "bdist_inno": thuban_bdist_inno,
865                      "data_dist": data_dist
866                    })                    })
867    
868    

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26