PyXR

c:\python24\lib \ distutils \ command \ install_scripts.py



0001 """distutils.command.install_scripts
0002 
0003 Implements the Distutils 'install_scripts' command, for installing
0004 Python scripts."""
0005 
0006 # contributed by Bastian Kleineidam
0007 
0008 # This module should be kept compatible with Python 1.5.2.
0009 
0010 __revision__ = "$Id: install_scripts.py,v 1.15 2002/11/29 19:45:58 akuchling Exp $"
0011 
0012 import os
0013 from distutils.core import Command
0014 from distutils import log
0015 from stat import ST_MODE
0016 
0017 class install_scripts (Command):
0018 
0019     description = "install scripts (Python or otherwise)"
0020 
0021     user_options = [
0022         ('install-dir=', 'd', "directory to install scripts to"),
0023         ('build-dir=','b', "build directory (where to install from)"),
0024         ('force', 'f', "force installation (overwrite existing files)"),
0025         ('skip-build', None, "skip the build steps"),
0026     ]
0027 
0028     boolean_options = ['force', 'skip-build']
0029 
0030 
0031     def initialize_options (self):
0032         self.install_dir = None
0033         self.force = 0
0034         self.build_dir = None
0035         self.skip_build = None
0036 
0037     def finalize_options (self):
0038         self.set_undefined_options('build', ('build_scripts', 'build_dir'))
0039         self.set_undefined_options('install',
0040                                    ('install_scripts', 'install_dir'),
0041                                    ('force', 'force'),
0042                                    ('skip_build', 'skip_build'),
0043                                   )
0044 
0045     def run (self):
0046         if not self.skip_build:
0047             self.run_command('build_scripts')
0048         self.outfiles = self.copy_tree(self.build_dir, self.install_dir)
0049         if os.name == 'posix':
0050             # Set the executable bits (owner, group, and world) on
0051             # all the scripts we just installed.
0052             for file in self.get_outputs():
0053                 if self.dry_run:
0054                     log.info("changing mode of %s", file)
0055                 else:
0056                     mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777
0057                     log.info("changing mode of %s to %o", file, mode)
0058                     os.chmod(file, mode)
0059 
0060     def get_inputs (self):
0061         return self.distribution.scripts or []
0062 
0063     def get_outputs(self):
0064         return self.outfiles or []
0065 
0066 # class install_scripts
0067 

Generated by PyXR 0.9.4
SourceForge.net Logo