1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
set(MIN_NODE_VERSION "14.00.0")
# Clean up directory
file(REMOVE_RECURSE ${PYTHON_PACKAGE_DST_DIR})
file(MAKE_DIRECTORY ${PYTHON_PACKAGE_DST_DIR}/open3d)
# Create python package. It contains:
# 1) Pure-python code and misc files, copied from ${PYTHON_PACKAGE_SRC_DIR}
# 2) The compiled python-C++ module, i.e. open3d.so (or the equivalents)
# Optionally other modules e.g. open3d_tf_ops.so may be included.
# 3) Configured files and supporting files
# 1) Pure-python code and misc files, copied from ${PYTHON_PACKAGE_SRC_DIR}
file(COPY ${PYTHON_PACKAGE_SRC_DIR}/
DESTINATION ${PYTHON_PACKAGE_DST_DIR}
)
# 2) The compiled python-C++ module, i.e. open3d.so (or the equivalents)
# Optionally other modules e.g. open3d_tf_ops.so may be included.
# Folder structure is base_dir/{cpu|cuda}/{pybind*.so|open3d_{torch|tf}_ops.so},
# so copy base_dir directly to ${PYTHON_PACKAGE_DST_DIR}/open3d
foreach(COMPILED_MODULE_PATH ${COMPILED_MODULE_PATH_LIST})
get_filename_component(COMPILED_MODULE_NAME ${COMPILED_MODULE_PATH} NAME)
get_filename_component(COMPILED_MODULE_ARCH_DIR ${COMPILED_MODULE_PATH} DIRECTORY)
get_filename_component(COMPILED_MODULE_BASE_DIR ${COMPILED_MODULE_ARCH_DIR} DIRECTORY)
foreach(ARCH cpu cuda)
if(IS_DIRECTORY "${COMPILED_MODULE_BASE_DIR}/${ARCH}")
file(INSTALL "${COMPILED_MODULE_BASE_DIR}/${ARCH}/" DESTINATION
"${PYTHON_PACKAGE_DST_DIR}/open3d/${ARCH}"
FILES_MATCHING PATTERN "${COMPILED_MODULE_NAME}")
endif()
endforeach()
endforeach()
# Include additional libraries that may be absent from the user system
# eg: libc++.so and libc++abi.so (needed by filament)
# The linker recognizes only library.so.MAJOR, so remove .MINOR from the filename
foreach(PYTHON_EXTRA_LIB ${PYTHON_EXTRA_LIBRARIES})
get_filename_component(PYTHON_EXTRA_LIB_REAL ${PYTHON_EXTRA_LIB} REALPATH)
get_filename_component(SO_VER_NAME ${PYTHON_EXTRA_LIB_REAL} NAME)
if (APPLE)
string(REGEX REPLACE "\\.([0-9]+)\\..*.dylib" ".\\1.dylib" SO_1_NAME ${SO_VER_NAME})
elseif (UNIX)
string(REGEX REPLACE "\\.so\\.([0-9]+)\\..*" ".so.\\1" SO_1_NAME ${SO_VER_NAME})
endif()
configure_file(${PYTHON_EXTRA_LIB_REAL} ${PYTHON_PACKAGE_DST_DIR}/open3d/${SO_1_NAME} COPYONLY)
endforeach()
# 3) Configured files and supporting files
configure_file("${PYTHON_PACKAGE_SRC_DIR}/setup.py"
"${PYTHON_PACKAGE_DST_DIR}/setup.py")
configure_file("${PYTHON_PACKAGE_SRC_DIR}/open3d/__init__.py"
"${PYTHON_PACKAGE_DST_DIR}/open3d/__init__.py")
configure_file("${PYTHON_PACKAGE_SRC_DIR}/tools/cli.py"
"${PYTHON_PACKAGE_DST_DIR}/open3d/tools/cli.py")
configure_file("${PYTHON_PACKAGE_SRC_DIR}/tools/app.py"
"${PYTHON_PACKAGE_DST_DIR}/open3d/app.py")
configure_file("${PYTHON_PACKAGE_SRC_DIR}/open3d/web_visualizer.py"
"${PYTHON_PACKAGE_DST_DIR}/open3d/web_visualizer.py")
configure_file("${PYTHON_PACKAGE_SRC_DIR}/js/lib/web_visualizer.js"
"${PYTHON_PACKAGE_DST_DIR}/js/lib/web_visualizer.js")
configure_file("${PYTHON_PACKAGE_SRC_DIR}/js/package.json"
"${PYTHON_PACKAGE_DST_DIR}/js/package.json")
configure_file("${PYTHON_PACKAGE_SRC_DIR}/../cpp/open3d/visualization/webrtc_server/html/webrtcstreamer.js"
"${PYTHON_PACKAGE_DST_DIR}/js/lib/webrtcstreamer.js")
file(COPY "${PYTHON_COMPILED_MODULE_DIR}/_build_config.py"
DESTINATION "${PYTHON_PACKAGE_DST_DIR}/open3d/")
if (BUILD_TENSORFLOW_OPS OR BUILD_PYTORCH_OPS)
# copy generated files
file(COPY "${PYTHON_PACKAGE_DST_DIR}/../ml"
DESTINATION "${PYTHON_PACKAGE_DST_DIR}/open3d/" )
endif()
if (BUNDLE_OPEN3D_ML)
file(COPY "${PYTHON_PACKAGE_DST_DIR}/../../open3d_ml/src/open3d_ml/ml3d"
DESTINATION "${PYTHON_PACKAGE_DST_DIR}/open3d/" )
file(RENAME "${PYTHON_PACKAGE_DST_DIR}/open3d/ml3d" "${PYTHON_PACKAGE_DST_DIR}/open3d/_ml3d")
endif()
set(requirement_files ${PYTHON_PACKAGE_SRC_DIR}/requirements.txt)
# Build Jupyter plugin.
if (BUILD_JUPYTER_EXTENSION)
if (WIN32 OR UNIX AND NOT LINUX_AARCH64)
message(STATUS "Jupyter support is enabled, building Jupyter plugin now.")
else()
message(FATAL_ERROR "Jupyter plugin is not supported on ARM.")
endif()
find_program(NODE node)
if (NODE)
message(STATUS "node found at: ${NODE}")
else()
message(STATUS "node not found.")
message(FATAL_ERROR "Please install Node.js."
"Visit https://nodejs.org/en/download/package-manager/ for details."
"For ubuntu, we recommend getting the latest version of Node.js from"
"https://github.com/nodesource/distributions/blob/master/README.md#installation-instructions.")
endif()
execute_process(COMMAND "${NODE}" --version
OUTPUT_VARIABLE NODE_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
STRING(REGEX REPLACE "v" "" NODE_VERSION ${NODE_VERSION})
message(STATUS "node version: ${NODE_VERSION}")
if (NODE_VERSION VERSION_LESS ${MIN_NODE_VERSION})
message(FATAL_ERROR "node version ${NODE_VERSION} is too old. "
"Please upgrade to ${MIN_NODE_VERSION} or higher.")
endif()
find_program(YARN yarn)
if (YARN)
message(STATUS "yarn found at: ${YARN}")
else()
message(FATAL_ERROR "yarn not found. You may install yarm globally by "
"npm install -g yarn.")
endif()
list(APPEND requirement_files
${PYTHON_PACKAGE_SRC_DIR}/requirements_jupyter_install.txt)
endif()
if (BUILD_SYCL_MODULE)
list(APPEND requirement_files ${PYTHON_PACKAGE_SRC_DIR}/requirements_sycl.txt)
endif()
# These will be installed when the user does `pip install open3d`.
execute_process(COMMAND ${CMAKE_COMMAND} -E cat ${requirement_files}
OUTPUT_FILE ${PYTHON_PACKAGE_DST_DIR}/requirements.txt
)
if (BUILD_GUI)
file(MAKE_DIRECTORY "${PYTHON_PACKAGE_DST_DIR}/open3d/resources/")
file(COPY ${GUI_RESOURCE_DIR}
DESTINATION "${PYTHON_PACKAGE_DST_DIR}/open3d/")
endif()
# Add all examples to installation directory.
file(MAKE_DIRECTORY "${PYTHON_PACKAGE_DST_DIR}/open3d/examples/")
file(COPY "${PYTHON_PACKAGE_SRC_DIR}/../examples/python/"
DESTINATION "${PYTHON_PACKAGE_DST_DIR}/open3d/examples")
file(COPY "${PYTHON_PACKAGE_SRC_DIR}/../examples/python/"
DESTINATION "${PYTHON_PACKAGE_DST_DIR}/open3d/examples")
|