File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,18 @@ class ModelTest:
41
41
42
42
43
43
def run_tests (model_tests : List [ModelTest ]) -> None :
44
+ # Test that we can import the portable_lib module - verifies RPATH is correct
45
+ print ("Testing portable_lib import..." )
46
+ try :
47
+ from executorch .extension .pybindings ._portable_lib import ( # noqa: F401
48
+ _load_for_executorch ,
49
+ )
50
+
51
+ print ("✓ Successfully imported _load_for_executorch from portable_lib" )
52
+ except ImportError as e :
53
+ print (f"✗ Failed to import portable_lib: { e } " )
54
+ raise
55
+
44
56
# Why are we doing this envvar shenanigans? Since we build the testers, which
45
57
# uses buck, we cannot run as root. This is a sneaky of getting around that
46
58
# test.
Original file line number Diff line number Diff line change @@ -869,6 +869,21 @@ if(EXECUTORCH_BUILD_PYBIND)
869
869
target_compile_options (portable_lib PUBLIC ${_pybind_compile_options} )
870
870
target_link_libraries (portable_lib PRIVATE ${_dep_libs} )
871
871
872
+ # Set RPATH to find PyTorch libraries relative to the installation location
873
+ # This goes from executorch/extension/pybindings up to site-packages, then to
874
+ # torch/lib
875
+ if (APPLE )
876
+ set_target_properties (
877
+ portable_lib PROPERTIES BUILD_RPATH "@loader_path/../../../torch/lib"
878
+ INSTALL_RPATH "@loader_path/../../../torch/lib"
879
+ )
880
+ else ()
881
+ set_target_properties (
882
+ portable_lib PROPERTIES BUILD_RPATH "$ORIGIN/../../../torch/lib"
883
+ INSTALL_RPATH "$ORIGIN/../../../torch/lib"
884
+ )
885
+ endif ()
886
+
872
887
install (
873
888
TARGETS portable_lib
874
889
EXPORT ExecuTorchTargets
You can’t perform that action at this time.
0 commit comments