diff options
author | Maxim Devaev <[email protected]> | 2023-06-28 14:39:38 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2023-06-28 14:39:38 +0300 |
commit | c129f54efa190599dc326e463af7ce32f493f763 (patch) | |
tree | 94b6a294230a630341f7d7349b35c913823389bb /setup.py | |
parent | a74044b086498cae1d6aed7cbf624e0b95e4f247 (diff) |
pikvm/pikvm#1037: Fixed building with setuptools 68.0.0
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 40 |
1 files changed, 15 insertions, 25 deletions
@@ -28,41 +28,31 @@ from setuptools import setup # ===== +class _Template(str): + def __init__(self, text: str) -> None: + self.__text = textwrap.dedent(text).strip() + + def __mod__(self, kv: dict) -> None: + kv = {"module_name": kv["ep"].module_name, **kv} + return (self.__text % (kv)) + + class _ScriptWriter(setuptools.command.easy_install.ScriptWriter): - template = textwrap.dedent(""" - # EASY-INSTALL-ENTRY-SCRIPT: {spec},{group},{name} + template = _Template(""" + # EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r - __requires__ = "{spec}" + __requires__ = %(spec)r - from {module} import main + from %(module_name)s import main - if __name__ == "__main__": + if __name__ == '__main__': main() - """).strip() - - @classmethod - def get_args(cls, dist, header=None): # type: ignore - if header is None: - header = cls.get_header() - spec = str(dist.as_requirement()) - for group_type in ["console", "gui"]: - group = group_type + "_scripts" - for (name, ep) in dist.get_entry_map(group).items(): - cls._ensure_safe_name(name) - script_text = cls.template.format( - spec=spec, - group=group, - name=name, - module=ep.module_name, - ) - yield from cls._get_script_args(group_type, name, header, script_text) + """) # ===== def main() -> None: setuptools.command.easy_install.ScriptWriter = _ScriptWriter - setuptools.command.easy_install.get_script_args = _ScriptWriter.get_script_args - setuptools.command.easy_install.get_script_header = _ScriptWriter.get_script_header setup( name="kvmd", |