Skip to content

Commit 0e5d80d

Browse files
larryliu0820facebook-github-bot
authored andcommitted
Fix CI job (#73)
Summary: Pull Request resolved: #73 Apparently in macos CI, python3 and python are pointing to different python environment. python3 -> /Library/Python/3.9/site-packages/ python -> /Users/ec2-user/runner/_work/_temp/miniconda/lib/python3.9/site-packages This diff is fixing the CI failure: ``` [2023-08-17T02:59:12.739+00:00] Local command: env -- "ASAN_OPTIONS=detect_leaks=0,detect_odr_violation=0" "GEN_DIR=GEN_DIR_DEPRECATED" "OUT=././../out" "SRCDIR=./." "SRCS=././link_torch.sh" /usr/bin/env bash -e buck-out/v2/gen/root/213ed1b7ab869379/third-party/__libtorch_gen__/sh/genrule.sh [2023-08-17T02:59:12.739+00:00] Stdout: Error: /Library/Python/3.9/site-packages/torch/lib/libtorch.dylib doesn't exist ``` Also adding `tomli` as a ci requirements due to the following error: ``` Error: Traceback (most recent call last): File "/Users/ec2-user/runner/_work/executorch/executorch/pytorch/executorch/build/extract_sources.py", line 18, in <module> import tomllib # Standard in 3.11 and later ModuleNotFoundError: No module named 'tomllib' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/ec2-user/runner/_work/executorch/executorch/pytorch/executorch/build/extract_sources.py", line 20, in <module> import tomli as tomllib ModuleNotFoundError: No module named 'tomli' CMake Error at CMakeLists.txt:101 (message): executorch: source list generation failed ``` Reviewed By: huydhn, cccclai Differential Revision: D48423480 fbshipit-source-id: 0a69c721da90878bda24f8d1c5d1ff59e583025b
1 parent 128c27a commit 0e5d80d

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

.github/workflows/pull.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
bash .ci/scripts/test.sh
5252
5353
# Test custom ops
54-
bash examples/custom_ops/test_custom_ops.sh buck2
54+
PYTHON_EXECUTABLE=python bash examples/custom_ops/test_custom_ops.sh buck2
5555
popd
5656
5757
cmake-build-test-linux:
@@ -90,5 +90,5 @@ jobs:
9090
bash .ci/scripts/setup-macos.sh
9191
9292
# Build and test custom ops
93-
bash examples/custom_ops/test_custom_ops.sh cmake
93+
PYTHON_EXECUTABLE=python bash examples/custom_ops/test_custom_ops.sh cmake
9494
popd

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ endif()
6262
if(NOT BUCK2)
6363
set(BUCK2 buck2)
6464
endif()
65+
if(NOT PYTHON_EXECUTABLE)
66+
set(PYTHON_EXECUTABLE python3)
67+
endif()
6568

6669
# TODO(dbort): Fix these warnings and remove this flag.
6770
set(_common_compile_options -Wno-deprecated-declarations)
@@ -87,7 +90,7 @@ if(NOT EXECUTORCH_SRCS_FILE)
8790
message(STATUS "executorch: Generating source lists")
8891
set(EXECUTORCH_SRCS_FILE "${CMAKE_CURRENT_BINARY_DIR}/executorch_srcs.cmake")
8992
execute_process(
90-
COMMAND python3 build/extract_sources.py --buck2=${BUCK2}
93+
COMMAND ${PYTHON_EXECUTABLE} build/extract_sources.py --buck2=${BUCK2}
9194
--config=build/cmake_deps.toml --out=${EXECUTORCH_SRCS_FILE}
9295
OUTPUT_VARIABLE gen_srcs_output
9396
ERROR_VARIABLE gen_srcs_error

examples/custom_ops/test_custom_ops.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ set -e
1414
test_buck2_custom_op_1() {
1515
local model_name='custom_ops_1'
1616
echo "Exporting ${model_name}.pte"
17-
python -m "examples.custom_ops.${model_name}"
17+
${PYTHON_EXECUTABLE} -m "examples.custom_ops.${model_name}"
1818
# should save file custom_ops_1.pte
1919

2020
echo 'Running executor_runner'
@@ -29,12 +29,14 @@ test_buck2_custom_op_1() {
2929
test_cmake_custom_op_1() {
3030
local model_name='custom_ops_1'
3131
echo "Exporting ${model_name}.pte"
32-
python -m "examples.custom_ops.${model_name}"
32+
${PYTHON_EXECUTABLE} -m "examples.custom_ops.${model_name}"
3333
# should save file custom_ops_1.pte
3434
(rm -rf cmake-out \
3535
&& mkdir cmake-out \
3636
&& cd cmake-out \
37-
&& cmake -DBUCK2=buck2 -DREGISTER_EXAMPLE_CUSTOM_OP_1=ON ..)
37+
&& cmake -DBUCK2=buck2 \
38+
-DREGISTER_EXAMPLE_CUSTOM_OP_1=ON \
39+
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" ..)
3840

3941
echo 'Building executor_runner'
4042
cmake --build cmake-out -j9
@@ -50,7 +52,7 @@ test_buck2_custom_op_2() {
5052
SO_LIB=$(buck2 build //examples/custom_ops:custom_ops_aot_lib_2 --show-output | grep "buck-out" | cut -d" " -f2)
5153

5254
echo "Exporting ${model_name}.pte"
53-
python -m "examples.custom_ops.${model_name}" --so_library="$SO_LIB"
55+
${PYTHON_EXECUTABLE} -m "examples.custom_ops.${model_name}" --so_library="$SO_LIB"
5456
# should save file custom_ops_2.pte
5557

5658
buck2 run //examples/executor_runner:executor_runner \
@@ -77,28 +79,33 @@ get_shared_lib_ext() {
7779

7880
test_cmake_custom_op_2() {
7981
local model_name='custom_ops_2'
80-
SITE_PACKAGES="$(python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
82+
SITE_PACKAGES="$(${PYTHON_EXECUTABLE} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
8183
CMAKE_PREFIX_PATH="${SITE_PACKAGES}/torch"
8284

8385
(rm -rf cmake-out \
8486
&& mkdir cmake-out \
8587
&& cd cmake-out \
8688
&& cmake -DBUCK2=buck2 \
8789
-DREGISTER_EXAMPLE_CUSTOM_OP_2=ON \
88-
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" ..)
90+
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
91+
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" ..)
8992

9093
echo 'Building executor_runner'
9194
cmake --build cmake-out -j4
9295

9396
EXT=$(get_shared_lib_ext)
9497
echo "Exporting ${model_name}.pte"
95-
python -m "examples.custom_ops.${model_name}" --so_library="cmake-out/examples/custom_ops/libcustom_ops_aot_lib$EXT"
98+
${PYTHON_EXECUTABLE} -m "examples.custom_ops.${model_name}" --so_library="cmake-out/examples/custom_ops/libcustom_ops_aot_lib$EXT"
9699
# should save file custom_ops_2.pte
97100

98101
echo 'Running executor_runner'
99102
cmake-out/executor_runner "--model_path=./${model_name}.pte"
100103
}
101104

105+
if [[ -z $PYTHON_EXECUTABLE ]];
106+
then
107+
PYTHON_EXECUTABLE=python3
108+
fi
102109
if [[ $1 == "cmake" ]];
103110
then
104111
test_cmake_custom_op_1

third-party/link_torch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ while getopts ":o:f:" opt; do
3333
esac
3434
done
3535

36-
LIB=$(python3 -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')
36+
LIB=$(python -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')
3737

3838
# delimiter ,
3939
export IFS=","

0 commit comments

Comments
 (0)