2000-05-11 22:58:29 -03:00
|
|
|
"""distutils.command.install_scripts
|
|
|
|
|
|
|
|
Implements the Distutils 'install_scripts' command, for installing
|
|
|
|
Python scripts."""
|
|
|
|
|
|
|
|
# contributed by Bastian Kleineidam
|
|
|
|
|
|
|
|
__revision__ = "$Id$"
|
|
|
|
|
2000-05-11 22:32:30 -03:00
|
|
|
import os
|
2000-05-24 22:19:18 -03:00
|
|
|
from distutils.core import Command
|
2000-05-11 22:32:30 -03:00
|
|
|
from stat import ST_MODE
|
2000-05-11 21:52:23 -03:00
|
|
|
|
2000-05-26 22:33:49 -03:00
|
|
|
class install_scripts (Command):
|
2000-05-11 21:52:23 -03:00
|
|
|
|
2000-05-26 22:33:49 -03:00
|
|
|
description = "install scripts (Python or otherwise)"
|
2000-05-11 21:52:23 -03:00
|
|
|
|
2000-05-24 22:19:18 -03:00
|
|
|
user_options = [
|
2000-05-26 22:33:49 -03:00
|
|
|
('install-dir=', 'd', "directory to install scripts to"),
|
2000-05-24 22:19:18 -03:00
|
|
|
('build-dir=','b', "build directory (where to install from)"),
|
|
|
|
('skip-build', None, "skip the build steps"),
|
|
|
|
]
|
|
|
|
|
|
|
|
def initialize_options (self):
|
|
|
|
self.install_dir = None
|
|
|
|
self.build_dir = None
|
|
|
|
self.skip_build = None
|
|
|
|
|
2000-05-11 21:52:23 -03:00
|
|
|
def finalize_options (self):
|
2000-05-24 22:19:18 -03:00
|
|
|
self.set_undefined_options('build', ('build_scripts', 'build_dir'))
|
|
|
|
self.set_undefined_options ('install',
|
|
|
|
('install_scripts', 'install_dir'),
|
|
|
|
('skip_build', 'skip_build'),
|
|
|
|
)
|
2000-05-11 21:52:23 -03:00
|
|
|
|
|
|
|
def run (self):
|
2000-05-24 22:19:18 -03:00
|
|
|
if not self.skip_build:
|
2000-05-27 14:27:23 -03:00
|
|
|
self.run_command('build_scripts')
|
2000-05-24 22:19:18 -03:00
|
|
|
self.outfiles = self.copy_tree (self.build_dir, self.install_dir)
|
2000-05-11 22:32:30 -03:00
|
|
|
if os.name == 'posix':
|
|
|
|
# Set the executable bits (owner, group, and world) on
|
|
|
|
# all the scripts we just installed.
|
2000-05-24 22:19:18 -03:00
|
|
|
for file in self.get_outputs():
|
2000-05-11 22:32:30 -03:00
|
|
|
if self.dry_run:
|
|
|
|
self.announce("changing mode of %s" % file)
|
|
|
|
else:
|
|
|
|
mode = (os.stat(file)[ST_MODE]) | 0111
|
|
|
|
self.announce("changing mode of %s to %o" % (file, mode))
|
|
|
|
os.chmod(file, mode)
|
2000-05-11 21:52:23 -03:00
|
|
|
|
2000-05-13 00:07:53 -03:00
|
|
|
def get_inputs (self):
|
|
|
|
return self.distribution.scripts or []
|
|
|
|
|
2000-05-24 22:19:18 -03:00
|
|
|
def get_outputs(self):
|
|
|
|
return self.outfiles or []
|
|
|
|
|
2000-05-11 22:32:30 -03:00
|
|
|
# class install_scripts
|