Skip to content

Commit e6b70ee

Browse files
committed
a
Signed-off-by: Vlad Gheorghiu <vsoftco@gmail.com>
1 parent df2244e commit e6b70ee

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

pyqpp/CMakeLists.txt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,14 @@ file(MAKE_DIRECTORY "${STUBGEN_OUTPUT_PATH}")
5151
add_custom_command(
5252
TARGET pyqpp
5353
POST_BUILD
54-
COMMAND ${Python3_EXECUTABLE} -m pybind11_stubgen pyqpp --output-dir
55-
${STUBGEN_OUTPUT_PATH} --ignore-all-errors
54+
# 1. Use ${CMAKE_COMMAND} -E env to correctly set PYTHONPATH
55+
# 2. Use $<TARGET_FILE_DIR:pyqpp> to dynamically find the .pyd location
56+
# (Release/Debug)
57+
COMMAND
58+
${CMAKE_COMMAND} -E env "PYTHONPATH=$<TARGET_FILE_DIR:pyqpp>"
59+
${Python3_EXECUTABLE} -m pybind11_stubgen pyqpp --output-dir
60+
"${STUBGEN_OUTPUT_PATH}" --ignore-all-errors
5661
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
5762
COMMENT "Generating Python stubs for pyqpp..."
58-
VERBATIM ENV PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/Release)
59-
60-
# Create an empty "py.typed" file in the build directory
61-
file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/py.typed")
62-
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/py.typed" DESTINATION pyqpp)
63-
64-
# Install the generated stub directory alongside the module
63+
VERBATIM) # Install the generated stub directory alongside the module
6564
install(DIRECTORY "${STUBGEN_OUTPUT_PATH}/pyqpp/" DESTINATION pyqpp)

0 commit comments

Comments
 (0)