Skip to content

Commit 51d41a2

Browse files
authored
支持多python版本编译 (#1371)
1 parent 7cfe84e commit 51d41a2

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

backends/npu/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ add_custom_command(
158158
${CMAKE_CURRENT_BINARY_DIR}/python/paddle_custom_device/npu/passes
159159
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/passes/*
160160
${CMAKE_CURRENT_BINARY_DIR}/python/paddle_custom_device/npu/passes
161-
COMMAND python3 ${CMAKE_CURRENT_BINARY_DIR}/setup.py bdist_wheel
161+
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/setup.py bdist_wheel
162162
DEPENDS ${CUSTOM_NPU_NAME}
163163
COMMENT "Packing whl packages------>>>")
164164

backends/npu/tools/compile.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Configuring cmake in build ...
4646
-DWITH_ATB=${WITH_ATB:-OFF}
4747
-DON_INFER=${ON_INFER:-OFF}
4848
-DWITH_COVERAGE=${WITH_COVERAGE:-OFF}
49+
-DPYTHON_VERSION=${PYTHON_VERSION:-""}
4950
========================================
5051
EOF
5152

@@ -58,6 +59,7 @@ cmake .. \
5859
-DWITH_ATB=${WITH_ATB:-OFF} \
5960
-DON_INFER=${ON_INFER:-OFF} \
6061
-DWITH_COVERAGE=${WITH_COVERAGE:-OFF} \
62+
-DPYTHON_VERSION=${PYTHON_VERSION:-""} \
6163
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON;cmake_error=$?
6264

6365
if [ "$cmake_error" != 0 ];then

cmake/paddle.cmake

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@
1212
# License for the specific language governing permissions and limitations under
1313
# the License.
1414

15-
find_package(Python ${PYTHON_VERSION} REQUIRED COMPONENTS Interpreter
16-
Development)
15+
if(NOT PYTHON_VERSION)
16+
find_package(Python REQUIRED COMPONENTS Interpreter Development)
17+
else()
18+
find_package(
19+
Python ${PYTHON_VERSION} REQUIRED
20+
COMPONENTS Interpreter Development
21+
EXACT)
22+
endif()
23+
24+
message(STATUS "Python_EXECUTABLE is ${Python_EXECUTABLE}")
1725
include_directories(${Python_INCLUDE_DIRS})
1826

1927
if(DEFINED ENV{PADDLE_CUSTOM_PATH})

0 commit comments

Comments
 (0)