Skip to content

Commit c5460bc

Browse files
committed
ET#72390: Hide all symbols except 'PyInit__mysqlxpb' in "_mysqlxpb" on macOS
Loading multiple binary Python plugins linked statically to different versions of the Protobuf library, caused crashes on macOS. By hiding all symbols except the initialization function, this is avoided.
1 parent ecfb667 commit c5460bc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cpydist/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import platform
3434
import shutil
3535
import sys
36+
import tempfile
3637

3738
from glob import glob
3839
from setuptools.command.build_ext import build_ext
@@ -603,6 +604,14 @@ def run(self):
603604
"The '_mysqlxpb' C extension will not be built")
604605
disabled.append(ext)
605606
continue
607+
if platform.system() == "Darwin":
608+
symbol_file = tempfile.NamedTemporaryFile()
609+
ext.extra_link_args.extend(
610+
["-exported_symbols_list", symbol_file.name]
611+
)
612+
with open(symbol_file.name, "w") as fp:
613+
fp.write("_PyInit__mysqlxpb")
614+
fp.write("\n")
606615
ext.include_dirs.append(self.with_protobuf_include_dir)
607616
ext.library_dirs.append(self._build_protobuf_lib_dir)
608617
ext.libraries.append(

0 commit comments

Comments
 (0)