Skip to content

Commit 45b3d22

Browse files
authored
Update setup.py
1 parent 2dae492 commit 45b3d22

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

setup.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ def using_system_libs():
138138
"""If true, don't build any dependencies. Use the libs that are already on the system."""
139139
return os.getenv('AWS_CRT_BUILD_USE_SYSTEM_LIBS') == '1'
140140

141+
def using_shared_libs():
142+
"""If true, the shared libs are used instead of the static ones, which is the default. Has no effect on Windows and Darwin."""
143+
return os.getenv('AWS_CRT_BUILD_USE_SHARED_LIBS') == '1'
141144

142145
def using_system_libcrypto():
143146
"""If true, don't build AWS-LC. Use the libcrypto that's already on the system."""
@@ -337,15 +340,18 @@ def awscrt_ext():
337340
extra_link_args += ['-framework', 'Security']
338341

339342
else: # unix
340-
# linker will prefer shared libraries over static if it can find both.
341-
# force linker to choose static variant by using using
342-
# "-l:libaws-c-common.a" syntax instead of just "-laws-c-common".
343+
# Linker will prefer shared libraries over static if it can find both.
344+
# This forces linker to choose static variant by using
345+
# "-l:libaws-c-common.a" syntax instead of just "-laws-c-common",
346+
# unless user has explicitely opted out from this by setting
347+
# `AWS_CRT_BUILD_USE_SHARED_LIBS` to `1`.
343348
#
344349
# This helps AWS developers creating Lambda applications from Brazil.
345350
# In Brazil, both shared and static libs are available.
346351
# But Lambda requires all shared libs to be explicitly packaged up.
347352
# So it's simpler to link them in statically and have less runtime dependencies.
348-
libraries = [':lib{}.a'.format(x) for x in libraries]
353+
if not using_shared_libs():
354+
libraries = [':lib{}.a'.format(x) for x in libraries]
349355

350356
# OpenBSD doesn't have librt; functions are found in libc instead.
351357
if not sys.platform.startswith('openbsd'):

0 commit comments

Comments
 (0)