From 03206cfae442684141ce1114921564701d9fa02c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Wed, 24 Apr 2024 11:27:10 +0200 Subject: [PATCH] setup: Refactor a little bit --- setup.py | 113 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/setup.py b/setup.py index e952e8c..9e24942 100644 --- a/setup.py +++ b/setup.py @@ -12,6 +12,57 @@ SOURCE_ROOT = Path(__file__).resolve().parent +FRIDA_EXTENSION = os.environ.get("FRIDA_EXTENSION", None) + + +def main(): + setup( + name="frida", + version=detect_version(), + description="Dynamic instrumentation toolkit for developers, reverse-engineers, and security researchers", + long_description=compute_long_description(), + long_description_content_type="text/markdown", + author="Frida Developers", + author_email="oleavr@frida.re", + url="https://frida.re", + install_requires=["typing_extensions; python_version<'3.11'"], + python_requires=">=3.7", + license="wxWindows Library Licence, Version 3.1", + keywords="frida debugger dynamic instrumentation inject javascript windows macos linux ios iphone ipad android qnx", + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Environment :: MacOS X", + "Environment :: Win32 (MS Windows)", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "License :: OSI Approved", + "Natural Language :: English", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: JavaScript", + "Topic :: Software Development :: Debuggers", + "Topic :: Software Development :: Libraries :: Python Modules", + ], + packages=["frida", "_frida"], + package_data={"frida": ["py.typed"], "_frida": ["py.typed", "__init__.pyi"]}, + ext_modules=[ + Extension( + name="_frida", + sources=["src/_frida.c"], + py_limited_api=True, + ) + ], + cmdclass={"build_ext": FridaPrebuiltExt if FRIDA_EXTENSION is not None else FridaDemandBuiltExt}, + zip_safe=False, + ) def detect_version() -> str: @@ -32,6 +83,10 @@ def detect_version() -> str: return version +def compute_long_description() -> str: + return (SOURCE_ROOT / "README.md").read_text(encoding="utf-8") + + def enumerate_releng_locations() -> Iterator[Path]: val = os.environ.get("MESON_SOURCE_ROOT") if val is not None: @@ -52,7 +107,7 @@ class FridaPrebuiltExt(build_ext): def build_extension(self, ext): target = self.get_ext_fullpath(ext.name) Path(target).parent.mkdir(parents=True, exist_ok=True) - shutil.copy(frida_extension, target) + shutil.copy(FRIDA_EXTENSION, target) class FridaDemandBuiltExt(build_ext): @@ -67,59 +122,5 @@ def build_extension(self, ext): shutil.copy(outputs[0], target) -frida_version = detect_version() -long_description = (SOURCE_ROOT / "README.md").read_text(encoding="utf-8") -frida_extension = os.environ.get("FRIDA_EXTENSION", None) - -cmdclass = {} -cmdclass["build_ext"] = FridaPrebuiltExt if frida_extension is not None else FridaDemandBuiltExt - - if __name__ == "__main__": - setup( - name="frida", - version=frida_version, - description="Dynamic instrumentation toolkit for developers, reverse-engineers, and security researchers", - long_description=long_description, - long_description_content_type="text/markdown", - author="Frida Developers", - author_email="oleavr@frida.re", - url="https://frida.re", - install_requires=["typing_extensions; python_version<'3.11'"], - python_requires=">=3.7", - license="wxWindows Library Licence, Version 3.1", - keywords="frida debugger dynamic instrumentation inject javascript windows macos linux ios iphone ipad android qnx", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Environment :: Console", - "Environment :: MacOS X", - "Environment :: Win32 (MS Windows)", - "Intended Audience :: Developers", - "Intended Audience :: Science/Research", - "License :: OSI Approved", - "Natural Language :: English", - "Operating System :: MacOS :: MacOS X", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX :: Linux", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: JavaScript", - "Topic :: Software Development :: Debuggers", - "Topic :: Software Development :: Libraries :: Python Modules", - ], - packages=["frida", "_frida"], - package_data={"frida": ["py.typed"], "_frida": ["py.typed", "__init__.pyi"]}, - ext_modules=[ - Extension( - name="_frida", - sources=["src/_frida.c"], - py_limited_api=True, - ) - ], - cmdclass=cmdclass, - zip_safe=False, - ) + main()