File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -590,7 +590,7 @@ endfunction()
590590# ---------------------------------------------------------------------------
591591
592592function (nanobind_add_stub name )
593- cmake_parse_arguments (PARSE_ARGV 1 ARG "VERBOSE;INCLUDE_PRIVATE;EXCLUDE_DOCSTRINGS;EXCLUDE_VALUES;INSTALL_TIME;RECURSIVE;EXCLUDE_FROM_ALL" "MODULE;COMPONENT;PATTERN_FILE;OUTPUT_PATH" "PYTHON_PATH;DEPENDS;MARKER_FILE;OUTPUT" )
593+ cmake_parse_arguments (PARSE_ARGV 1 ARG "VERBOSE;INCLUDE_PRIVATE;EXCLUDE_DOCSTRINGS;EXCLUDE_VALUES;INSTALL_TIME;RECURSIVE;EXCLUDE_FROM_ALL" "MODULE;COMPONENT;PATTERN_FILE;OUTPUT_PATH" "PYTHON_PATH;LIB_PATH; DEPENDS;MARKER_FILE;OUTPUT" )
594594
595595 if (EXISTS ${NB_DIR} /src/stubgen.py)
596596 set (NB_STUBGEN "${NB_DIR} /src/stubgen.py" )
@@ -626,6 +626,10 @@ function (nanobind_add_stub name)
626626 list (APPEND NB_STUBGEN_ARGS -i "${PYTHON_PATH} " )
627627 endforeach ()
628628
629+ foreach (LIB_PATH IN LISTS ARG_LIB_PATH)
630+ list (APPEND NB_STUBGEN_ARGS -L "${LIB_PATH} " )
631+ endforeach ()
632+
629633 if (ARG_PATTERN_FILE)
630634 list (APPEND NB_STUBGEN_ARGS -p "${ARG_PATTERN_FILE} " )
631635 endif ()
Original file line number Diff line number Diff line change @@ -1285,6 +1285,16 @@ def parse_options(args: List[str]) -> argparse.Namespace:
12851285 help = "add the directory to the Python import path (can specify multiple times)" ,
12861286 )
12871287
1288+ parser .add_argument (
1289+ "-L" ,
1290+ "--lib-path" ,
1291+ action = "append" ,
1292+ metavar = "PATH" ,
1293+ dest = "lib_paths" ,
1294+ default = [],
1295+ help = "add directory to shared library search path (can specify multiple times)"
1296+ )
1297+
12881298 parser .add_argument (
12891299 "-m" ,
12901300 "--module" ,
@@ -1426,6 +1436,7 @@ def add_pattern(query: str, lines: List[str]):
14261436
14271437def main (args : Optional [List [str ]] = None ) -> None :
14281438 import sys
1439+ import os
14291440
14301441 # Ensure that the current directory is on the path
14311442 if "" not in sys .path and "." not in sys .path :
@@ -1446,6 +1457,16 @@ def main(args: Optional[List[str]] = None) -> None:
14461457 for i in opt .imports :
14471458 sys .path .insert (0 , i )
14481459
1460+ if os .name == 'nt' :
1461+ for lib_path in opt .lib_paths :
1462+ os .add_dll_directory (lib_path )
1463+ else :
1464+ lib_env = "DYLD_LIBRARY_PATH" if sys .platform == "darwin" else "LD_LIBRARY_PATH"
1465+ old_value = os .environ .get (lib_env , "" )
1466+ paths_str = ":" .join (opt .lib_paths )
1467+ if paths_str :
1468+ os .environ [lib_env ] = f"{ paths_str } :{ old_value } " if old_value else paths_str
1469+
14491470 for i , mod in enumerate (opt .modules ):
14501471 if not opt .quiet :
14511472 if i > 0 :
You can’t perform that action at this time.
0 commit comments