Skip to content

Commit 00c11f3

Browse files
larsgebclaude
andcommitted
Stage m1_gpu_ops package in build/ after pybind11 build
Add a POST_BUILD step that copies _m1_gpu_ops.so and __init__.py into build/m1_gpu_ops/, so that sys.path.insert(0, "build") + import m1_gpu_ops works for in-tree use (notebooks, CI smoke test) without needing pip install. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a6fbaf0 commit 00c11f3

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,14 @@ if(pybind11_FOUND)
251251
${FOUNDATION_FRAMEWORK}
252252
${METALKIT_FRAMEWORK}
253253
)
254+
# Stage the package in build/m1_gpu_ops/ so that adding build/ to sys.path
255+
# is enough for in-tree use (notebooks, CI smoke test, etc.)
256+
add_custom_command(TARGET _m1_gpu_ops POST_BUILD
257+
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/m1_gpu_ops"
258+
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:_m1_gpu_ops>" "${CMAKE_BINARY_DIR}/m1_gpu_ops/"
259+
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/python/__init__.py" "${CMAKE_BINARY_DIR}/m1_gpu_ops/"
260+
COMMENT "Staging m1_gpu_ops package in build/"
261+
)
254262
# Install the module into the python package directory
255263
install(TARGETS _m1_gpu_ops DESTINATION m1_gpu_ops)
256264
install(FILES python/__init__.py DESTINATION m1_gpu_ops)

0 commit comments

Comments
 (0)