bdist_rpm.py 900 B

12345678910111213141516171819202122232425262728293031
  1. import distutils.command.bdist_rpm as orig
  2. class bdist_rpm(orig.bdist_rpm):
  3. """
  4. Override the default bdist_rpm behavior to do the following:
  5. 1. Run egg_info to ensure the name and version are properly calculated.
  6. 2. Always run 'install' using --single-version-externally-managed to
  7. disable eggs in RPM distributions.
  8. """
  9. def run(self):
  10. # ensure distro name is up-to-date
  11. self.run_command('egg_info')
  12. orig.bdist_rpm.run(self)
  13. def _make_spec_file(self):
  14. spec = orig.bdist_rpm._make_spec_file(self)
  15. spec = [
  16. line.replace(
  17. "setup.py install ",
  18. "setup.py install --single-version-externally-managed "
  19. ).replace(
  20. "%setup",
  21. "%setup -n %{name}-%{unmangled_version}"
  22. )
  23. for line in spec
  24. ]
  25. return spec