diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2000-05-13 03:06:56 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2000-05-13 03:06:56 (GMT) |
commit | ba0506b3492a13f5c8cec7598bf2b5f9735ac7b2 (patch) | |
tree | 9a05a7d24009b717c155b770597ae81593e9d58c | |
parent | a04d80712711cd810f0796eff22bae17684d34d4 (diff) | |
download | cpython-ba0506b3492a13f5c8cec7598bf2b5f9735ac7b2.zip cpython-ba0506b3492a13f5c8cec7598bf2b5f9735ac7b2.tar.gz cpython-ba0506b3492a13f5c8cec7598bf2b5f9735ac7b2.tar.bz2 |
Drastically simplified by taking advantage of the "install" command's
new flexibility, specifically the 'root' option. Now, we just use
"install" to do a fake installation into a temporary directory
(the 'bdist_dir' option, which derives from the 'bdist_base' option of
"bdist"), and then tar/zip up that directory. This means that dumb
built distributions are now relative to the root directory, rather than
the prefix or exec-prefix; this is probably a feature, but does make
them slightly less flexible.
-rw-r--r-- | Lib/distutils/command/bdist_dumb.py | 95 |
1 files changed, 21 insertions, 74 deletions
diff --git a/Lib/distutils/command/bdist_dumb.py b/Lib/distutils/command/bdist_dumb.py index 23672a6..2de2bef 100644 --- a/Lib/distutils/command/bdist_dumb.py +++ b/Lib/distutils/command/bdist_dumb.py @@ -17,7 +17,9 @@ class bdist_dumb (Command): description = "create a \"dumb\" built distribution" - user_options = [('format=', 'f', + user_options = [('bdist-dir=', 'd', + "temporary directory for creating the distribution"), + ('format=', 'f', "archive format to create (tar, ztar, gztar, zip)"), ('keep-tree', 'k', "keep the pseudo-installation tree around after " + @@ -29,6 +31,7 @@ class bdist_dumb (Command): def initialize_options (self): + self.bdist_dir = None self.format = None self.keep_tree = 0 @@ -36,6 +39,10 @@ class bdist_dumb (Command): def finalize_options (self): + if self.bdist_dir is None: + bdist_base = self.get_peer_option('bdist', 'bdist_base') + self.bdist_dir = os.path.join(bdist_base, 'dumb') + if self.format is None: try: self.format = self.default_format[os.name] @@ -50,91 +57,31 @@ class bdist_dumb (Command): def run (self): self.run_peer ('build') - install = self.find_peer ('install') - inputs = install.get_inputs () - outputs = install.get_outputs () - assert (len (inputs) == len (outputs)) - - # First, strip the installation base directory (prefix or - # exec-prefix) from all the output filenames. - self.strip_base_dirs (outputs, install) - # Figure out where to copy them to: "build/bdist" by default; this - # directory masquerades as prefix/exec-prefix (ie. we'll make the - # archive from 'output_dir'). - build_base = self.get_peer_option ('build', 'build_base') - output_dir = os.path.join (build_base, "bdist") + # XXX don't use 'self.find_peer()', because it always runs + # 'ensure_ready()' on the command object; we explictly want a + # command object that has *not* been finalized, so we can set + # options on it! (The option we set, 'root', is so that we can do + # a proper "fake install" using this install command object.) + install = self.distribution.find_command_obj('install') + install.root = self.bdist_dir - # Copy the built files to the pseudo-installation tree. - self.make_install_tree (output_dir, inputs, outputs) + self.announce ("installing to %s" % self.bdist_dir) + install.ensure_ready() + install.run() # And make an archive relative to the root of the # pseudo-installation tree. archive_basename = "%s.%s" % (self.distribution.get_fullname(), get_platform()) - print "output_dir = %s" % output_dir + print "self.bdist_dir = %s" % self.bdist_dir print "self.format = %s" % self.format self.make_archive (archive_basename, self.format, - root_dir=output_dir) + root_dir=self.bdist_dir) if not self.keep_tree: - remove_tree (output_dir, self.verbose, self.dry_run) + remove_tree (self.bdist_dir, self.verbose, self.dry_run) # run() - - def strip_base_dirs (self, outputs, install_cmd): - # XXX this throws away the prefix/exec-prefix distinction, and - # means we can only correctly install the resulting archive on a - # system where prefix == exec-prefix (but at least we can *create* - # it on one where they differ). I don't see a way to fix this - # without either 1) generating two archives, one for prefix and one - # for exec-prefix, or 2) putting absolute paths in the archive - # rather than making them relative to one of the prefixes. - - base = install_cmd.install_base + os.sep - platbase = install_cmd.install_platbase + os.sep - b_len = len (base) - pb_len = len (platbase) - for i in range (len (outputs)): - if outputs[i][0:b_len] == base: - outputs[i] = outputs[i][b_len:] - elif outputs[i][0:pb_len] == platbase: - outputs[i] = outputs[i][pb_len:] - else: - raise DistutilsInternalError, \ - ("installation output filename '%s' doesn't start " + - "with either install_base ('%s') or " + - "install_platbase ('%s')") % \ - (outputs[i], base, platbase) - - # strip_base_dirs() - - - def make_install_tree (self, output_dir, inputs, outputs): - - assert (len(inputs) == len(outputs)) - - # Create all the directories under 'output_dir' necessary to - # put 'outputs' there. - create_tree (output_dir, outputs, - verbose=self.verbose, dry_run=self.dry_run) - - - # XXX this bit of logic is duplicated in sdist.make_release_tree(): - # would be nice to factor it out... - if hasattr (os, 'link'): # can make hard links on this system - link = 'hard' - msg = "making hard links in %s..." % output_dir - else: # nope, have to copy - link = None - msg = "copying files to %s..." % output_dir - - for i in range (len(inputs)): - output = os.path.join (output_dir, outputs[i]) - self.copy_file (inputs[i], output, link=link) - - # make_install_tree () - - # class bdist_dumb |