Skip to content

Commit d35e913

Browse files
committed
[Infra] Auto install pybind11-stubgen in cmake stage
1 parent 378c948 commit d35e913

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

paddle/fluid/operators/generator/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,35 @@ function(install_py_jinja2)
5757
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -U jinja2)
5858
endfunction()
5959

60+
function(install_py_pybind11_stubgen)
61+
# check install
62+
execute_process(
63+
COMMAND
64+
${PYTHON_EXECUTABLE} "-c"
65+
"import re, pybind11_stubgen; print(re.compile('/__init__.py.*').sub('',pybind11_stubgen.__file__))"
66+
RESULT_VARIABLE _pybind11_stubgen_status
67+
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
68+
69+
if(_pybind11_stubgen_status EQUAL 0)
70+
# check version
71+
execute_process(
72+
COMMAND ${PYTHON_EXECUTABLE} "-c"
73+
"import pybind11_stubgen; print(pybind11_stubgen.__version__)"
74+
OUTPUT_VARIABLE _pybind11_stubgen_version
75+
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
76+
77+
if(_pybind11_stubgen_version)
78+
return()
79+
endif()
80+
endif()
81+
82+
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -U
83+
pybind11-stubgen)
84+
endfunction()
85+
6086
install_py_pyyaml()
6187
install_py_jinja2()
88+
install_py_pybind11_stubgen()
6289

6390
# parse ops
6491
set(parsed_op_dir ${CMAKE_BINARY_DIR}/paddle/phi/ops/yaml)

0 commit comments

Comments
 (0)