Skip to content

Commit 872144e

Browse files
committed
fixes to make libonnxruntime path placement more generic
1 parent 5152aaf commit 872144e

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

lib/ortex/util.ex

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
defmodule Ortex.Util do
22
def copy_ort_libs() do
3+
4+
build_root = Path.absname(:code.priv_dir(:ortex)) |> Path.dirname
5+
36
rust_env =
4-
case Mix.env() do
5-
:prod -> "release"
7+
case Path.join([build_root, "native/ortex/release"]) |> File.ls do
8+
{:ok, _} -> "release"
69
_ -> "debug"
710
end
811

912
case :os.type() do
1013
{:win32, _} ->
1114
Path.wildcard(
1215
Path.join([
13-
"./_build",
14-
Mix.env() |> Atom.to_string(),
15-
"lib/ortex/native/ortex",
16+
build_root,
17+
"native/ortex",
1618
rust_env,
1719
"libonnxruntime*.dll*"
1820
])
@@ -21,9 +23,8 @@ defmodule Ortex.Util do
2123
{:unix, :darwin} ->
2224
Path.wildcard(
2325
Path.join([
24-
"./_build/",
25-
Mix.env() |> Atom.to_string(),
26-
"lib/ortex/native/ortex",
26+
build_root,
27+
"native/ortex",
2728
rust_env,
2829
"libonnxruntime*.dylib*"
2930
])
@@ -32,9 +33,8 @@ defmodule Ortex.Util do
3233
{:unix, _} ->
3334
Path.wildcard(
3435
Path.join([
35-
"./_build/",
36-
Mix.env() |> Atom.to_string(),
37-
"lib/ortex/native/ortex",
36+
build_root,
37+
"native/ortex",
3838
rust_env,
3939
"libonnxruntime*.so*"
4040
])
@@ -44,9 +44,8 @@ defmodule Ortex.Util do
4444
File.cp!(
4545
x,
4646
Path.join([
47-
"./_build",
48-
Mix.env() |> Atom.to_string(),
49-
"lib/ortex/priv/native/",
47+
:code.priv_dir(:ortex),
48+
"native",
5049
Path.basename(x)
5150
])
5251
)

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ defmodule Ortex.MixProject do
4444
defp package do
4545
[
4646
files: ~w(lib .formatter.exs mix.exs README* LICENSE* native/ortex/src/
47-
native/ortex/Cargo.lock native/ortex/Cargo.toml),
47+
native/ortex/Cargo.lock native/ortex/Cargo.toml native/ortex/.cargo/config.toml),
4848
licenses: ["MIT"],
4949
links: %{"GitHub" => "https://github.com/relaypro-open/ortex"},
5050
description: "ONNX Runtime bindings for Elixir"

0 commit comments

Comments
 (0)