diff options
| author | Tarek Ziade <tarek@ziade.org> | 2010-09-19 10:15:10 +0200 |
|---|---|---|
| committer | Tarek Ziade <tarek@ziade.org> | 2010-09-19 10:15:10 +0200 |
| commit | 5afe5844d0b204e55801b6a02fab6b2e18254448 (patch) | |
| tree | a65ade5921380d541e2cc30ad307a30917b54d27 /distutils2/command/install_scripts.py | |
| parent | addfd74a36216143ed49f25da1cd6030902dad91 (diff) | |
| download | disutils2-5afe5844d0b204e55801b6a02fab6b2e18254448.tar.gz | |
moved everything in the same dir - we want to include docs/ in the release
Diffstat (limited to 'distutils2/command/install_scripts.py')
| -rw-r--r-- | distutils2/command/install_scripts.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/distutils2/command/install_scripts.py b/distutils2/command/install_scripts.py new file mode 100644 index 0000000..fa7587e --- /dev/null +++ b/distutils2/command/install_scripts.py @@ -0,0 +1,62 @@ +"""distutils.command.install_scripts + +Implements the Distutils 'install_scripts' command, for installing +Python scripts.""" + +# contributed by Bastian Kleineidam + +__revision__ = "$Id: install_scripts.py 68943 2009-01-25 22:09:10Z tarek.ziade $" + +import os +from distutils2.core import Command +from distutils2 import log +from stat import ST_MODE + +class install_scripts (Command): + + description = "install scripts (Python or otherwise)" + + user_options = [ + ('install-dir=', 'd', "directory to install scripts to"), + ('build-dir=','b', "build directory (where to install from)"), + ('force', 'f', "force installation (overwrite existing files)"), + ('skip-build', None, "skip the build steps"), + ] + + boolean_options = ['force', 'skip-build'] + + + def initialize_options (self): + self.install_dir = None + self.force = 0 + self.build_dir = None + self.skip_build = None + + def finalize_options (self): + self.set_undefined_options('build', ('build_scripts', 'build_dir')) + self.set_undefined_options('install', + ('install_scripts', 'install_dir'), + 'force', 'skip_build') + + def run (self): + if not self.skip_build: + self.run_command('build_scripts') + self.outfiles = self.copy_tree(self.build_dir, self.install_dir) + if os.name == 'posix': + # Set the executable bits (owner, group, and world) on + # all the scripts we just installed. + for file in self.get_outputs(): + if self.dry_run: + log.info("changing mode of %s", file) + else: + mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777 + log.info("changing mode of %s to %o", file, mode) + os.chmod(file, mode) + + def get_inputs (self): + return self.distribution.scripts or [] + + def get_outputs(self): + return self.outfiles or [] + +# class install_scripts |
