bdist_rpm.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import distutils.command.bdist_rpm as orig
  2. import warnings
  3. from setuptools import SetuptoolsDeprecationWarning
  4. class bdist_rpm(orig.bdist_rpm):
  5. """
  6. Override the default bdist_rpm behavior to do the following:
  7. 1. Run egg_info to ensure the name and version are properly calculated.
  8. 2. Always run 'install' using --single-version-externally-managed to
  9. disable eggs in RPM distributions.
  10. """
  11. def run(self):
  12. warnings.warn(
  13. "bdist_rpm is deprecated and will be removed in a future "
  14. "version. Use bdist_wheel (wheel packages) instead.",
  15. SetuptoolsDeprecationWarning,
  16. )
  17. # ensure distro name is up-to-date
  18. self.run_command('egg_info')
  19. orig.bdist_rpm.run(self)
  20. def _make_spec_file(self):
  21. spec = orig.bdist_rpm._make_spec_file(self)
  22. spec = [
  23. line.replace(
  24. "setup.py install ",
  25. "setup.py install --single-version-externally-managed "
  26. ).replace(
  27. "%setup",
  28. "%setup -n %{name}-%{unmangled_version}"
  29. )
  30. for line in spec
  31. ]
  32. return spec