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