Skip to content

Commit ca53e2b

Browse files
authored
[Infra] Auto install pybind11-stubgen in cmake stage (#71911)
1 parent a27df21 commit ca53e2b

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

paddle/fluid/pybind/CMakeLists.txt

+19
Original file line numberDiff line numberDiff line change
@@ -735,4 +735,23 @@ if(WITH_PYTHON)
735735
get_property(os_dependency_modules GLOBAL PROPERTY OS_DEPENDENCY_MODULES)
736736
target_link_libraries(${SHARD_LIB_NAME} ${os_dependency_modules})
737737

738+
function(install_py_pybind11_stubgen)
739+
# check install
740+
execute_process(
741+
COMMAND
742+
${PYTHON_EXECUTABLE} "-c"
743+
"import re, pybind11_stubgen; print(re.compile('/__init__.py.*').sub('',pybind11_stubgen.__file__))"
744+
RESULT_VARIABLE _pybind11_stubgen_status
745+
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
746+
747+
if(_pybind11_stubgen_status EQUAL 0)
748+
return()
749+
endif()
750+
751+
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -U
752+
pybind11-stubgen)
753+
endfunction()
754+
755+
install_py_pybind11_stubgen()
756+
738757
endif()

python/requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ astor
77
opt_einsum==3.3.0
88
networkx
99
typing_extensions
10-
pybind11-stubgen==2.5.1 # generate stub file from pybind11 C++ APIs [build]

0 commit comments

Comments
 (0)