/[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 66 by bh, Tue Sep 11 11:45:09 2001 UTC revision 67 by bh, Thu Oct 18 14:50:21 2001 UTC
# Line 22  from distutils.command.install import in Line 22  from distutils.command.install import in
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  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 250  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 690  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 731  setup(name = "Thuban", Line 861  setup(name = "Thuban",
861                    "install_local": InstallLocal,                    "install_local": InstallLocal,
862                    "install": ThubanInstall,                    "install": ThubanInstall,
863                    "bdist_rpm": thuban_bdist_rpm,                    "bdist_rpm": thuban_bdist_rpm,
864                    "bdist_inno": thuban_bdist_inno                    "bdist_inno": thuban_bdist_inno,
865                      "data_dist": data_dist
866                    })                    })
867    
868    

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26