Author: reinhard
Date: 2007-06-06 02:34:59 -0500 (Wed, 06 Jun 2007)
New Revision: 9667
Modified:
trunk/gnue-common/src/setup/GSetup.py
Log:
Allow *.dist_template processing for all tools.
Modified: trunk/gnue-common/src/setup/GSetup.py
===================================================================
--- trunk/gnue-common/src/setup/GSetup.py 2007-06-06 06:54:31 UTC (rev 9666)
+++ trunk/gnue-common/src/setup/GSetup.py 2007-06-06 07:34:59 UTC (rev 9667)
@@ -1,4 +1,4 @@
-# GNU Enterprise Common Library - Installation Helper For Packages
+# GNU Enterprise Common Library - Installation Helper For Tools
#
# This file is part of GNU Enterprise.
#
@@ -26,6 +26,7 @@
import os
from distutils import log
from distutils.core import setup
+from distutils.filelist import FileList
import distutils.command.sdist
import distutils.command.build
import distutils.command.install
@@ -73,10 +74,62 @@
_setup.do_build_files ('sdist')
distutils.command.sdist.sdist.run (self)
+ def prune_file_list(self):
+ distutils.command.sdist.sdist.prune_file_list(self)
+ self.filelist.exclude_pattern('*.dist_template', anchor=0)
+
def make_release_tree (self, base_dir, files):
distutils.command.sdist.sdist.make_release_tree (self, base_dir, files)
+ self.process_templates(base_dir)
_setup.do_build_svnrev (os.path.join(base_dir, 'src', 'svnrev.py'))
+ def process_templates(self, target):
+
+ # Build list of files to be processed.
+ filelist = FileList()
+ if filelist.include_pattern('*.dist_template', anchor=0) == 0:
+ # Nothing to do.
+ return
+
+ # FIXME: For compatibility with old packages not yet using the version
+ # module. Change to unconditional import in gnue-common 0.8.
+ try:
+ from src import version
+ except:
+ return
+
+ # List of keywords to replace.
+ keywords = {
+ ':PACKAGE:': self.distribution.get_name(),
+ ':TITLE:': self.distribution.get_description(),
+ ':VERSION:': self.distribution.get_version(),
+ ':MAJOR:': str(version.major),
+ ':MINOR:': str(version.minor),
+ ':PHASE:': str(version.phase),
+ ':BUILD:': str(version.build),
+ ':SVN:': str(version.svn)}
+ # Hack for version numbering schemes that are limited to x.y.z.
+ if version.phase == 'final':
+ keywords[':FINAL:'] = str(version.build)
+ else:
+ keywords[':FINAL:'] = '0'
+
+ for src in filelist.files:
+ dst = os.path.join(target, src[:-14])
+ args = (src, dst, keywords)
+ self.execute(self.__process_template, args,
+ "generating %s from %s" % (dst, src))
+
+ def __process_template(self, src, dst, keywords):
+ infile = open(src, 'r')
+ content = infile.read()
+ infile.close()
+ for keyword, value in keywords.iteritems():
+ content = content.replace(keyword, value)
+ outfile = open(dst, 'w')
+ outfile.write(content)
+ outfile.close()
+
# =============================================================================
# build: if done from SVN, build files to be installed first
# =============================================================================
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.