Skip to content

Commit 92314c8

Browse files
zdevitofacebook-github-bot
authored andcommitted
re-enable copy of python files, but be careful that the copy is only … (pytorch#14982)
Summary: …done once This allow no-op build to work correctly even when BUILD_CAFFE2_OPS is on. Pull Request resolved: pytorch#14982 Differential Revision: D13413960 Pulled By: zdevito fbshipit-source-id: 6e5412a8c375af8a47c76f548cdd31cff15f3853
1 parent 71e0cb5 commit 92314c8

File tree

15 files changed

+19
-79
lines changed

15 files changed

+19
-79
lines changed

caffe2/CMakeLists.txt

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ endif()
471471
# rebuild step. The long-term fix should be to clean up these rules so they
472472
# only rerun when needed.
473473

474-
if (BUILD_PYTHON AND BUILD_CAFFE2_OPS)
474+
if (BUILD_PYTHON)
475475
# Python site-packages
476476
# Get canonical directory for python site packages (relative to install
477477
# location). It varies from system to system.
@@ -628,37 +628,22 @@ if (BUILD_PYTHON AND BUILD_CAFFE2_OPS)
628628
endif()
629629

630630
# Finally, Copy all python files to build directory
631-
# Generate and create all needed __init__.py files, if they aren't already
632-
# present in the current source tree.
633-
message(STATUS "Automatically generating missing __init__.py files.")
634-
caffe_autogen_init_py_files()
635-
636631
# Create a custom target that copies all python files.
637632
file(GLOB_RECURSE PYTHON_SRCS RELATIVE ${PROJECT_SOURCE_DIR}
638633
"${PROJECT_SOURCE_DIR}/caffe2/*.py")
639-
add_custom_target(python_copy_files ALL)
640-
if(MSVC OR CMAKE_GENERATOR MATCHES "Ninja")
641-
# ninja fails when the command line is too long so we split
642-
# the target into several. This would be beneficial for VS also
643-
# since it build targets in parallel but not custom commands
644-
foreach(python_src ${PYTHON_SRCS})
645-
get_filename_component(dir ${python_src} DIRECTORY)
646-
string(SHA1 name_hash "${python_src}")
647-
# get_filename_component(name_we ${python_src} NAME_WE)
648-
add_custom_target(python_copy_files_${name_hash}
649-
COMMAND ${CMAKE_COMMAND} -E copy
650-
${PROJECT_SOURCE_DIR}/${python_src} ${CMAKE_BINARY_DIR}/${dir})
651-
add_dependencies(python_copy_files python_copy_files_${name_hash})
652-
endforeach()
653-
else()
654-
foreach(python_src ${PYTHON_SRCS})
655-
get_filename_component(dir ${python_src} DIRECTORY)
656-
add_custom_command(
657-
TARGET python_copy_files PRE_BUILD
658-
COMMAND ${CMAKE_COMMAND} -E copy
659-
${PROJECT_SOURCE_DIR}/${python_src} ${CMAKE_BINARY_DIR}/${dir})
660-
endforeach()
661-
endif()
634+
635+
set(build_files)
636+
foreach(python_src ${PYTHON_SRCS})
637+
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${python_src}
638+
DEPENDS ${PROJECT_SOURCE_DIR}/${python_src}
639+
COMMAND ${CMAKE_COMMAND} -E copy
640+
${PROJECT_SOURCE_DIR}/${python_src}
641+
${CMAKE_BINARY_DIR}/${python_src})
642+
list(APPEND build_files ${CMAKE_BINARY_DIR}/${python_src})
643+
endforeach()
644+
645+
add_custom_target(python_copy_files ALL DEPENDS ${build_files})
646+
662647

663648
# Install commands
664649
# Pick up static python files

caffe2/contrib/aten/docs/__init__.py

Whitespace-only changes.

caffe2/contrib/cuda-convnet2/make-data/__init__.py

Whitespace-only changes.

caffe2/contrib/script/examples/__init__.py

Whitespace-only changes.

caffe2/core/__init__.py

Whitespace-only changes.

caffe2/core/nomnigraph/__init__.py

Whitespace-only changes.

caffe2/experiments/__init__.py

Whitespace-only changes.

caffe2/experiments/python/__init__.py

Whitespace-only changes.

caffe2/perfkernels/__init__.py

Whitespace-only changes.

caffe2/python/mint/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)