Skip to content

Commit be37d21

Browse files
committed
Find portable_lib.so in pip package during cmake build (#5961)
Summary: * Rename `_portable_lib.cpython-3.<distribution info>.so` to `_portable_lib.so` so it can be found by CMake `find_library()`. This can be achieved by setting `SETUPTOOLS_EXT_SUFFIX`. * Since `executorch-config.cmake` is also being used to find installed libraries such as `executorch.a`, `xnnpack_backend.a`, add a condition to tell if `executorch-config.cmake` is being used in cmake-out or site-packages. Pull Request resolved: #5961 Reviewed By: metascroy Differential Revision: D64014291 Pulled By: larryliu0820 fbshipit-source-id: 2757f2883d3f836e9efd45676f792c12f742e63d
1 parent 8c599a8 commit be37d21

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

build/packaging/env_var_script_linux.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# Enable pybindings so that users can execute ExecuTorch programs from python.
1212
export EXECUTORCH_BUILD_PYBIND=1
1313

14+
# Override extension suffix to be ".so", skipping package info such as
15+
# "cpython-311-x86_64-linux-gnu"
16+
export SETUPTOOLS_EXT_SUFFIX=".so"
17+
1418
# Ensure that CMAKE_ARGS is defined before referencing it. Defaults to empty
1519
# if not defined.
1620
export CMAKE_ARGS="${CMAKE_ARGS:-}"

build/packaging/env_var_script_m1.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# Enable pybindings so that users can execute ExecuTorch programs from python.
1212
export EXECUTORCH_BUILD_PYBIND=1
1313

14+
# Override extension suffix to be ".so", skipping package info such as
15+
# "cpython-311-darwin"
16+
export SETUPTOOLS_EXT_SUFFIX=".so"
17+
1418
# Ensure that CMAKE_ARGS is defined before referencing it. Defaults to empty
1519
# if not defined.
1620
export CMAKE_ARGS="${CMAKE_ARGS:-}"

setup.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,11 @@ def run(self):
423423
"devtools/bundled_program/schema/scalar_type.fbs",
424424
"devtools/bundled_program/serialize/scalar_type.fbs",
425425
),
426+
# Install executorch-config.cmake to the root of the package.
427+
(
428+
"build/executorch-config.cmake",
429+
"executorch-config.cmake",
430+
),
426431
]
427432
for src, dst in src_to_dst:
428433
dst = os.path.join(dst_root, dst)

0 commit comments

Comments
 (0)