bdist_rpm.py 1.3 KB

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