From 9671514a8bd7cf69e2970e054eafc1f26185cf76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Wed, 18 Dec 2019 04:32:07 +0100 Subject: [PATCH] Patch extension DLL to match Python on Windows So we can support any 3.x version like on the other platforms. The Python 3.x ABI is stable so there is no need to build an extension for each minor version. Due to the limited dynamic linking support on Windows, however, there's no way around hard-coding the Python DLL name in the extension it is compiled for. As we don't expect users to install via easy_install on Python 3.x, but assume they're using pip, we just have to tweak our setup.py so it fixes up the extension after grabbing it from the .egg. --- setup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.py b/setup.py index d99ca99..831dc19 100755 --- a/setup.py +++ b/setup.py @@ -11,6 +11,7 @@ except: from StringIO import StringIO as BytesIO import os import platform +import re from setuptools import setup from setuptools.command.build_ext import build_ext from setuptools.extension import Extension @@ -135,6 +136,8 @@ class FridaPrebuiltExt(build_ext): egg_zip = zipfile.ZipFile(egg_file) extension_member = [info for info in egg_zip.infolist() if info.filename.endswith(target_extension)][0] extension_data = egg_zip.read(extension_member) + if system == 'Windows' and python_major_version >= 3: + extension_data = re.sub(b"python[3-9][0-9].dll", "python{0}{1}.dll".format(*python_version).encode('utf-8'), extension_data) with open(target, 'wb') as f: f.write(extension_data) else: