@@ -5,6 +5,7 @@ defmodule Ortex.Util do
55 Elixir can use
66 """
77 def copy_ort_libs ( ) do
8+ suppress_warning? = suppress_copy_warning? ( )
89 build_root = Path . absname ( :code . priv_dir ( :ortex ) ) |> Path . dirname ( )
910 ort_lib_location = System . get_env ( "ORT_LIB_LOCATION" )
1011 destination_dir = Path . join ( [ :code . priv_dir ( :ortex ) , "native" ] )
@@ -37,16 +38,11 @@ defmodule Ortex.Util do
3738 Destination: #{ destination_dir }
3839 """
3940
40- onnx_runtime_paths == [ ] and test_env? ( ) ->
41+ onnx_runtime_paths == [ ] and ( test_env? ( ) or suppress_warning? ) ->
4142 :ok
4243
4344 onnx_runtime_paths == [ ] ->
44- IO . warn ( """
45- Unable to locate libonnxruntime binaries.
46- Searched: #{ Enum . join ( search_patterns , ", " ) }
47- Destination: #{ destination_dir }
48- Set ORT_LIB_LOCATION or run mix compile to build the NIF.
49- """ )
45+ :ok
5046
5147 true ->
5248 Enum . each ( onnx_runtime_paths , fn path ->
@@ -72,7 +68,9 @@ defmodule Ortex.Util do
7268 expanded = Path . expand ( path )
7369
7470 if File . dir? ( expanded ) do
75- [ lib_glob ( expanded ) ]
71+ [ expanded , Path . join ( expanded , "lib" ) , Path . join ( expanded , "lib64" ) ]
72+ |> Enum . filter ( & File . dir? / 1 )
73+ |> Enum . map ( & lib_glob / 1 )
7674 else
7775 [ expanded ]
7876 end
@@ -113,4 +111,16 @@ defmodule Ortex.Util do
113111 System . get_env ( "MIX_ENV" ) == "test"
114112 end
115113 end
114+
115+ defp suppress_copy_warning? ( ) do
116+ truthy_env? ( "ORTEX_SKIP_COMPILE" ) or truthy_env? ( "ORTEX_SKIP_DOWNLOAD" ) or
117+ truthy_env? ( "ORT_PREFER_DYNAMIC_LINK" )
118+ end
119+
120+ defp truthy_env? ( name ) do
121+ case System . get_env ( name ) do
122+ nil -> false
123+ value -> String . downcase ( value ) in [ "1" , "true" , "yes" , "on" ]
124+ end
125+ end
116126end
0 commit comments