bdist_rpm.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from ..dist import Distribution
  2. from ..warnings import SetuptoolsDeprecationWarning
  3. import distutils.command.bdist_rpm as orig
  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. distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution
  12. def run(self) -> None:
  13. SetuptoolsDeprecationWarning.emit(
  14. "Deprecated command",
  15. """
  16. bdist_rpm is deprecated and will be removed in a future version.
  17. Use bdist_wheel (wheel packages) instead.
  18. """,
  19. see_url="https://github.com/pypa/setuptools/issues/1988",
  20. due_date=(2023, 10, 30), # Deprecation introduced in 22 Oct 2021.
  21. )
  22. # ensure distro name is up-to-date
  23. self.run_command('egg_info')
  24. orig.bdist_rpm.run(self)
  25. def _make_spec_file(self):
  26. spec = orig.bdist_rpm._make_spec_file(self)
  27. return [
  28. line.replace(
  29. "setup.py install ",
  30. "setup.py install --single-version-externally-managed ",
  31. ).replace("%setup", "%setup -n %{name}-%{unmangled_version}")
  32. for line in spec
  33. ]