John Snow | ea1213b | 2021-05-27 17:16:54 -0400 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | """ |
| 3 | QEMU tooling installer script |
| 4 | Copyright (c) 2020-2021 John Snow for Red Hat, Inc. |
| 5 | """ |
| 6 | |
| 7 | import setuptools |
John Snow | 2ddaeb7 | 2022-02-07 16:30:39 -0500 | [diff] [blame] | 8 | from setuptools.command import bdist_egg |
| 9 | import sys |
John Snow | ea1213b | 2021-05-27 17:16:54 -0400 | [diff] [blame] | 10 | import pkg_resources |
| 11 | |
| 12 | |
John Snow | 2ddaeb7 | 2022-02-07 16:30:39 -0500 | [diff] [blame] | 13 | class bdist_egg_guard(bdist_egg.bdist_egg): |
| 14 | """ |
| 15 | Protect against bdist_egg from being executed |
| 16 | |
| 17 | This prevents calling 'setup.py install' directly, as the 'install' |
| 18 | CLI option will invoke the deprecated bdist_egg hook. "pip install" |
| 19 | calls the more modern bdist_wheel hook, which is what we want. |
| 20 | """ |
| 21 | def run(self): |
| 22 | sys.exit( |
| 23 | 'Installation directly via setup.py is not supported.\n' |
| 24 | 'Please use `pip install .` instead.' |
| 25 | ) |
| 26 | |
| 27 | |
John Snow | ea1213b | 2021-05-27 17:16:54 -0400 | [diff] [blame] | 28 | def main(): |
| 29 | """ |
| 30 | QEMU tooling installer |
| 31 | """ |
| 32 | |
| 33 | # https://medium.com/@daveshawley/safely-using-setup-cfg-for-metadata-1babbe54c108 |
| 34 | pkg_resources.require('setuptools>=39.2') |
| 35 | |
John Snow | 2ddaeb7 | 2022-02-07 16:30:39 -0500 | [diff] [blame] | 36 | setuptools.setup(cmdclass={'bdist_egg': bdist_egg_guard}) |
John Snow | ea1213b | 2021-05-27 17:16:54 -0400 | [diff] [blame] | 37 | |
| 38 | |
| 39 | if __name__ == '__main__': |
| 40 | main() |