Skip to content

Commit e380236

Browse files
committed
[pybind] Add back extension suffix for portable lib shared object in wheel
Summary: Initially our portable lib prebuilt library is named as: ``` _portable_lib.cpython-310-x86_64-linux-gnu.so ``` Where it includes an `EXT_SUFFIX` `cpython-310-x86_64-linux-gnu` consists of architecture and build OS information. This is enforced by `setuptools` following PEP 3149 and there's no good way to change this behavior. which is easier to be found by `find_package()` macro in CMake. However #5961 is breaking the other prebuilt libraries such as `libcustom_ops_aot_lib.so` which depends on the original `_portable_lib.cpython-310-x86_64-linux-gnu.so` name in its RPATH. This PR is a fix that reverts #5961 and restore the full name during packaging, but try to match the `EXT_SUFFIX` in CMake to be able to find the .so file. Test Plan: ```bash python -c "from executorch.extension.llm.custom_ops import sdpa_with_kv_cache" ``` Does not throw `_portable_lib.cpython-310-x86_64-linux-gnu.so` not found error. Reviewers: Subscribers: Tasks: Tags:
1 parent 7510f8c commit e380236

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

build/executorch-wheel-config.cmake

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,20 @@
2121
#
2222
cmake_minimum_required(VERSION 3.19)
2323

24-
# Find prebuilt _portable_lib.so. This file should be installed under
24+
# Find prebuilt _portable_lib.<EXT_SUFFIX>.so. This file should be installed under
2525
# <site-packages>/executorch/share/cmake
26-
find_library(_portable_lib_LIBRARY _portable_lib.so PATHS "${CMAKE_CURRENT_LIST_DIR}/../../extension/pybindings/")
26+
27+
# Get the Python version and platform information
28+
execute_process(
29+
COMMAND python -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))"
30+
OUTPUT_VARIABLE EXT_SUFFIX
31+
OUTPUT_STRIP_TRAILING_WHITESPACE
32+
)
33+
find_library(
34+
_portable_lib_LIBRARY
35+
NAMES _portable_lib${EXT_SUFFIX}
36+
PATHS "${CMAKE_CURRENT_LIST_DIR}/../../extension/pybindings/"
37+
)
2738
set(EXECUTORCH_LIBRARIES)
2839
set(EXECUTORCH_FOUND OFF)
2940
if(_portable_lib_LIBRARY)

setup.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -687,10 +687,6 @@ def get_ext_modules() -> List[Extension]:
687687
return ext_modules
688688

689689

690-
# Override extension suffix to be ".so", skipping package info such as
691-
# "cpython-311-darwin"
692-
os.environ["SETUPTOOLS_EXT_SUFFIX"] = ".so"
693-
694690
setup(
695691
version=Version.string(),
696692
# TODO(dbort): Could use py_modules to restrict the set of modules we

0 commit comments

Comments
 (0)