commands.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright 2013 Hewlett-Packard Development Company, L.P.
  2. # All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15. import os
  16. from setuptools.command import easy_install
  17. from pbr.hooks import base
  18. from pbr import options
  19. from pbr import packaging
  20. class CommandsConfig(base.BaseConfig):
  21. section = 'global'
  22. def __init__(self, config):
  23. super(CommandsConfig, self).__init__(config)
  24. self.commands = self.config.get('commands', "")
  25. def save(self):
  26. self.config['commands'] = self.commands
  27. super(CommandsConfig, self).save()
  28. def add_command(self, command):
  29. self.commands = "%s\n%s" % (self.commands, command)
  30. def hook(self):
  31. self.add_command('pbr.packaging.LocalEggInfo')
  32. self.add_command('pbr.packaging.LocalSDist')
  33. self.add_command('pbr.packaging.LocalInstallScripts')
  34. self.add_command('pbr.packaging.LocalDevelop')
  35. self.add_command('pbr.packaging.LocalRPMVersion')
  36. self.add_command('pbr.packaging.LocalDebVersion')
  37. if os.name != 'nt':
  38. easy_install.get_script_args = packaging.override_get_script_args
  39. if os.path.exists('.testr.conf') and packaging.have_testr():
  40. # There is a .testr.conf file. We want to use it.
  41. self.add_command('pbr.packaging.TestrTest')
  42. elif self.config.get('nosetests', False) and packaging.have_nose():
  43. # We seem to still have nose configured
  44. self.add_command('pbr.packaging.NoseTest')
  45. use_egg = options.get_boolean_option(
  46. self.pbr_config, 'use-egg', 'PBR_USE_EGG')
  47. # We always want non-egg install unless explicitly requested
  48. if 'manpages' in self.pbr_config or not use_egg:
  49. self.add_command('pbr.packaging.LocalInstall')
  50. else:
  51. self.add_command('pbr.packaging.InstallWithGit')