bundle.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import textwrap
  2. from pip.locations import build_prefix, src_prefix
  3. from pip.util import display_path, backup_dir
  4. from pip.log import logger
  5. from pip.exceptions import InstallationError
  6. from pip.commands.install import InstallCommand
  7. class BundleCommand(InstallCommand):
  8. """Create pybundles (archives containing multiple packages)."""
  9. name = 'bundle'
  10. usage = """
  11. %prog [options] <bundle name>.pybundle <package>..."""
  12. summary = 'DEPRECATED. Create pybundles.'
  13. bundle = True
  14. def __init__(self, *args, **kw):
  15. super(BundleCommand, self).__init__(*args, **kw)
  16. # bundle uses different default source and build dirs
  17. build_opt = self.parser.get_option("--build")
  18. build_opt.default = backup_dir(build_prefix, '-bundle')
  19. src_opt = self.parser.get_option("--src")
  20. src_opt.default = backup_dir(src_prefix, '-bundle')
  21. self.parser.set_defaults(**{
  22. src_opt.dest: src_opt.default,
  23. build_opt.dest: build_opt.default,
  24. })
  25. def run(self, options, args):
  26. logger.deprecated('1.6', "DEPRECATION: 'pip bundle' and support for installing from *.pybundle files is deprecated. "
  27. "See https://github.com/pypa/pip/pull/1046")
  28. if not args:
  29. raise InstallationError('You must give a bundle filename')
  30. # We have to get everything when creating a bundle:
  31. options.ignore_installed = True
  32. logger.notify('Putting temporary build files in %s and source/develop files in %s'
  33. % (display_path(options.build_dir), display_path(options.src_dir)))
  34. self.bundle_filename = args.pop(0)
  35. requirement_set = super(BundleCommand, self).run(options, args)
  36. return requirement_set