From f74dad67f89b939402340e312139924f910ddde2 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Wed, 4 Jan 2023 18:02:07 +0000 Subject: [PATCH] Try static linking --- python/dist/setup.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/dist/setup.py b/python/dist/setup.py index 278560cc28..831e3ee18e 100755 --- a/python/dist/setup.py +++ b/python/dist/setup.py @@ -33,6 +33,7 @@ import glob import os +import sys import sysconfig # We must use setuptools, not distutils, because we need to use the @@ -54,6 +55,10 @@ def GetVersion(): return __version__ # pylint:disable=undefined-variable current_dir = os.path.dirname(os.path.abspath(__file__)) +extra_link_args = [] + +if sys.platform.startswith('win'): + extra_link_args = ["-static"] setup( name='protobuf', @@ -80,6 +85,6 @@ setup( namespace_packages=['google'], packages=find_packages(), install_requires=[], - ext_modules= [Extension('google._upb._message', glob.glob('google/protobuf/*.c') + glob.glob('python/*.c') + glob.glob('upb/*.c') + glob.glob('upb/**/*.c') + glob.glob('utf8_range/*.c'), include_dirs=[current_dir, os.path.join(current_dir, 'utf8_range')], language = 'c')], + ext_modules= [Extension('google._upb._message', glob.glob('google/protobuf/*.c') + glob.glob('python/*.c') + glob.glob('upb/*.c') + glob.glob('upb/**/*.c') + glob.glob('utf8_range/*.c'), include_dirs=[current_dir, os.path.join(current_dir, 'utf8_range')], language = 'c', extra_link_args=extra_link_args)], python_requires='>=3.7', )