Skip to content

Commit d1912ed

Browse files
authored
support add library_dirs from environment variable (#712)
1 parent 0bdff88 commit d1912ed

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,33 @@ AWS_CRT_BUILD_USE_SYSTEM_LIBS=1 python3 -m pip install .
117117

118118
If these dependencies are available as both static and shared libs, you can force the static ones to be used by setting: `AWS_CRT_BUILD_FORCE_STATIC_LIBS=1`
119119

120+
### AWS_EXTRA_LIB_DIR ###
121+
122+
If you need to add additional library directories for the linker to search,
123+
set environment variable `AWS_EXTRA_LIB_DIR` while building from source.
124+
This sets the `library_dirs` parameter for the setuptools Extension, which tells the linker
125+
where to find libraries during the build process.
126+
These directories supplement (not replace) the linker's default search paths.
127+
This is useful when you have custom library installations in non-standard locations.
128+
129+
For more details about `library_dirs` , see the [setuptools Extension documentation](https://setuptools.pypa.io/en/latest/userguide/ext_modules.html).
130+
131+
For a single directory:
132+
133+
```sh
134+
AWS_EXTRA_LIB_DIR=/path/to/libs python3 -m pip install .
135+
```
136+
137+
For multiple directories, separate them with the OS path separator ( `:` on Unix/macOS, `;` on Windows):
138+
139+
```sh
140+
# Unix/macOS
141+
AWS_EXTRA_LIB_DIR=/path/to/libs:/another/path python3 -m pip install .
142+
143+
# Windows
144+
AWS_EXTRA_LIB_DIR=C:\path\to\libs;D:\another\path python3 -m pip install .
145+
```
146+
120147
### Windows SDK Version
121-
aws-crt-python builds against windows sdk version `10.0.17763.0`. This is the minimal version required for TLS 1.3 support on Windows. If you need a different Windows SDK version, you can set environment variable `AWS_CRT_WINDOWS_SDK_VERSION=<version>` while building from source:
148+
149+
aws-crt-python builds against windows sdk version `10.0.17763.0` . This is the minimal version required for TLS 1.3 support on Windows. If you need a different Windows SDK version, you can set environment variable `AWS_CRT_WINDOWS_SDK_VERSION=<version>` while building from source:

setup.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,18 @@ def forcing_static_libs():
199199
return os.getenv('AWS_CRT_BUILD_FORCE_STATIC_LIBS') == '1'
200200

201201

202+
def get_extra_library_dirs():
203+
"""Return list of additional library directories from AWS_EXTRA_LIB_DIR env var.
204+
205+
Supports multiple directories separated by os.pathsep (: on Unix, ; on Windows).
206+
Returns empty list if not set.
207+
"""
208+
extra_dirs = os.getenv('AWS_EXTRA_LIB_DIR', '')
209+
if not extra_dirs:
210+
return []
211+
return [d for d in extra_dirs.split(os.pathsep) if d]
212+
213+
202214
class AwsLib:
203215
def __init__(self, name, extra_cmake_args=[], libname=None):
204216
self.name = name
@@ -532,6 +544,7 @@ def awscrt_ext():
532544
return setuptools.Extension(
533545
'_awscrt',
534546
language='c',
547+
library_dirs=get_extra_library_dirs(),
535548
libraries=libraries,
536549
sources=glob.glob('source/*.c'),
537550
extra_compile_args=extra_compile_args,

0 commit comments

Comments
 (0)