mirror of
https://github.com/python/cpython.git
synced 2025-08-02 08:02:56 +00:00
Patch from Bastien Kleineidam:
adds the 'install_data' and 'install_scripts' commands; these two are trivial thanks to the 'install_misc' base class in cmd.py. (Minor tweaks and commentary by me; the code is untested so far.)
This commit is contained in:
parent
bb8c71d563
commit
b2e3bb3d6a
6 changed files with 68 additions and 1 deletions
|
@ -344,5 +344,35 @@ class Command:
|
||||||
# class Command
|
# class Command
|
||||||
|
|
||||||
|
|
||||||
|
class install_misc (Command):
|
||||||
|
"""Common base class for installing some files in a subdirectory.
|
||||||
|
Currently used by install_data and install_scripts.
|
||||||
|
"""
|
||||||
|
|
||||||
|
user_options = [('install-dir=', 'd', "directory to install the files to")]
|
||||||
|
|
||||||
|
def initialize_options (self):
|
||||||
|
self.install_dir = None
|
||||||
|
self.outfiles = None
|
||||||
|
|
||||||
|
def _install_dir_from(self, dirname):
|
||||||
|
self.set_undefined_options('install', (dirname, 'install_dir'))
|
||||||
|
|
||||||
|
def _copydata(self, filelist):
|
||||||
|
self.outfiles = []
|
||||||
|
if not filelist:
|
||||||
|
return
|
||||||
|
self.mkpath(self.install_dir)
|
||||||
|
for f in filelist:
|
||||||
|
self.outfiles.append(self.copy_file (f, self.install_dir))
|
||||||
|
|
||||||
|
def _outputdata(self, filelist):
|
||||||
|
if self.outfiles is not None:
|
||||||
|
return self.outfiles
|
||||||
|
# XXX de-lambda-fy
|
||||||
|
return map(lambda x: os.path.join(self.install_dir, x), filelist)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print "ok"
|
print "ok"
|
||||||
|
|
|
@ -11,6 +11,8 @@ __all__ = ['build',
|
||||||
'build_clib',
|
'build_clib',
|
||||||
'install',
|
'install',
|
||||||
'install_lib',
|
'install_lib',
|
||||||
|
'install_scripts',
|
||||||
|
'install_data',
|
||||||
'clean',
|
'clean',
|
||||||
'sdist',
|
'sdist',
|
||||||
'bdist',
|
'bdist',
|
||||||
|
|
|
@ -90,7 +90,10 @@ class install (Command):
|
||||||
# (func, command) where 'func' is a function to call that returns
|
# (func, command) where 'func' is a function to call that returns
|
||||||
# true if 'command' (the sub-command name, a string) needs to be
|
# true if 'command' (the sub-command name, a string) needs to be
|
||||||
# run. If 'func' is None, assume that 'command' must always be run.
|
# run. If 'func' is None, assume that 'command' must always be run.
|
||||||
sub_commands = [(None, 'install_lib')]
|
sub_commands = [(None, 'install_lib'),
|
||||||
|
(None, 'install_scripts'),
|
||||||
|
(None, 'install_data'),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def initialize_options (self):
|
def initialize_options (self):
|
||||||
|
|
14
Lib/distutils/command/install_data.py
Normal file
14
Lib/distutils/command/install_data.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
from distutils.cmd import install_misc
|
||||||
|
|
||||||
|
class install_data (install_misc):
|
||||||
|
|
||||||
|
description = "install data files"
|
||||||
|
|
||||||
|
def finalize_options (self):
|
||||||
|
self._install_dir_from('install_data')
|
||||||
|
|
||||||
|
def run (self):
|
||||||
|
self._copydata(self.distribution.data)
|
||||||
|
|
||||||
|
def get_outputs (self):
|
||||||
|
return self._outputdata(self.distribution.data)
|
16
Lib/distutils/command/install_scripts.py
Normal file
16
Lib/distutils/command/install_scripts.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
from distutils.cmd import install_misc
|
||||||
|
|
||||||
|
class install_scripts(install_misc):
|
||||||
|
|
||||||
|
description = "install scripts"
|
||||||
|
# XXX needed?
|
||||||
|
user_options = [('install-dir=', 'd', "directory to install to")]
|
||||||
|
|
||||||
|
def finalize_options (self):
|
||||||
|
self._install_dir_from('install_scripts')
|
||||||
|
|
||||||
|
def run (self):
|
||||||
|
self._copydata(self.distribution.scripts)
|
||||||
|
|
||||||
|
def get_outputs(self):
|
||||||
|
return self._outputdata(self.distribution.scripts)
|
|
@ -154,6 +154,8 @@ class Distribution:
|
||||||
self.ext_package = None
|
self.ext_package = None
|
||||||
self.include_dirs = None
|
self.include_dirs = None
|
||||||
self.extra_path = None
|
self.extra_path = None
|
||||||
|
self.scripts = None
|
||||||
|
self.data = None
|
||||||
|
|
||||||
# And now initialize bookkeeping stuff that can't be supplied by
|
# And now initialize bookkeeping stuff that can't be supplied by
|
||||||
# the caller at all. 'command_obj' maps command names to
|
# the caller at all. 'command_obj' maps command names to
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue