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
|
2002-06-04 17:14:43 -03:00
|
|
|
from distutils import log
|
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)"),
|
2000-09-12 22:02:25 -03:00
|
|
|
('force', 'f', "force installation (overwrite existing files)"),
|
2000-05-24 22:19:18 -03:00
|
|
|
('skip-build', None, "skip the build steps"),
|
|
|
|
]
|
|
|
|
|
2000-09-24 22:41:15 -03:00
|
|
|
boolean_options = ['force', 'skip-build']
|
|
|
|
|
|
|
|
|
2000-05-24 22:19:18 -03:00
|
|
|
def initialize_options (self):
|
|
|
|
self.install_dir = None
|
2000-09-12 22:02:25 -03:00
|
|
|
self.force = 0
|
2000-05-24 22:19:18 -03:00
|
|
|
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'))
|
2000-09-30 15:27:54 -03:00
|
|
|
self.set_undefined_options('install',
|
|
|
|
('install_scripts', 'install_dir'),
|
|
|
|
('force', 'force'),
|
|
|
|
('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-09-12 22:02:25 -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:
|
2002-06-04 17:30:10 -03:00
|
|
|
log.info("changing mode of %s", file)
|
2000-05-11 22:32:30 -03:00
|
|
|
else:
|
2002-01-31 18:08:38 -04:00
|
|
|
mode = ((os.stat(file)[ST_MODE]) | 0111) & 07777
|
2002-06-04 17:14:43 -03:00
|
|
|
log.info("changing mode of %s to %o", file, mode)
|
2000-05-11 22:32:30 -03:00
|
|
|
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
|