CMakeLists.txt 3.3 KB
Newer Older
G
guru4elephant 已提交
1
if (CLIENT_ONLY)
M
MRXLT 已提交
2 3 4 5
    file(GLOB_RECURSE SERVING_CLIENT_PY_FILES paddle_serving_client/*.py)
    set(PY_FILES ${SERVING_CLIENT_PY_FILES})
    SET(PACKAGE_NAME "serving_client")
    set(SETUP_LOG_FILE "setup.py.client.log")
G
guru4elephant 已提交
6 7 8
endif()

if (NOT CLIENT_ONLY)
M
MRXLT 已提交
9 10 11 12 13 14 15 16
    if (NOT WITH_GPU)
        file(GLOB_RECURSE SERVING_SERVER_PY_FILES paddle_serving_server/*.py)
    else()
        file(GLOB_RECURSE SERVING_SERVER_PY_FILES paddle_serving_server_gpu/*.py)
    endif()
        set(PY_FILES ${SERVING_SERVER_PY_FILES})
        SET(PACKAGE_NAME "serving_server")
        set(SETUP_LOG_FILE "setup.py.server.log")
G
guru4elephant 已提交
17
endif()
G
guru4elephant 已提交
18

G
guru4elephant 已提交
19 20
if (CLIENT_ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.client.in
G
guru4elephant 已提交
21
    ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
G
guru4elephant 已提交
22 23 24
endif()

if (NOT CLIENT_ONLY)
M
MRXLT 已提交
25 26 27 28 29 30 31
    if (NOT WITH_GPU)
        configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.server.in
            ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
    else()
        configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.server_gpu.in
            ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
    endif()
G
guru4elephant 已提交
32
endif()
G
guru4elephant 已提交
33

G
guru4elephant 已提交
34
set(SERVING_CLIENT_CORE ${PADDLE_SERVING_BINARY_DIR}/core/general-client/serving_client.so)
G
guru4elephant 已提交
35 36 37

message("python env: " ${py_env})

G
guru4elephant 已提交
38
if (CLIENT_ONLY)
G
guru4elephant 已提交
39 40
add_custom_command(
	OUTPUT ${PADDLE_SERVING_BINARY_DIR}/.timestamp
41 42
	COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/paddle_serving_client/ ${PADDLE_SERVING_BINARY_DIR}/python/
	COMMAND ${CMAKE_COMMAND} -E copy ${PADDLE_SERVING_BINARY_DIR}/core/general-client/serving_client.so ${PADDLE_SERVING_BINARY_DIR}/python/paddle_serving_client/
G
guru4elephant 已提交
43 44
	COMMAND env ${py_env} ${PYTHON_EXECUTABLE} setup.py bdist_wheel
	DEPENDS ${SERVING_CLIENT_CORE} sdk_configure_py_proto ${PY_FILES})
G
guru4elephant 已提交
45
add_custom_target(paddle_python ALL DEPENDS serving_client ${PADDLE_SERVING_BINARY_DIR}/.timestamp)
G
guru4elephant 已提交
46 47 48
endif()

if (NOT CLIENT_ONLY)
M
MRXLT 已提交
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
    if(NOT WITH_GPU)
        add_custom_command(
            OUTPUT ${PADDLE_SERVING_BINARY_DIR}/.timestamp
            COMMAND cp -r ${CMAKE_CURRENT_SOURCE_DIR}/paddle_serving_server/ ${PADDLE_SERVING_BINARY_DIR}/python/
            COMMAND env ${py_env} ${PYTHON_EXECUTABLE} setup.py bdist_wheel
            DEPENDS ${SERVING_SERVER_CORE} server_config_py_proto ${PY_FILES})
        add_custom_target(paddle_python ALL DEPENDS ${PADDLE_SERVING_BINARY_DIR}/.timestamp)
    else()
        add_custom_command(
            OUTPUT ${PADDLE_SERVING_BINARY_DIR}/.timestamp
            COMMAND cp -r
            ${CMAKE_CURRENT_SOURCE_DIR}/paddle_serving_server_gpu/ ${PADDLE_SERVING_BINARY_DIR}/python/
            COMMAND env ${py_env} ${PYTHON_EXECUTABLE} setup.py bdist_wheel
            DEPENDS ${SERVING_SERVER_CORE} server_config_py_proto ${PY_FILES})
        add_custom_target(paddle_python ALL DEPENDS ${PADDLE_SERVING_BINARY_DIR}/.timestamp)
    endif()
G
guru4elephant 已提交
65
endif()
G
guru4elephant 已提交
66 67

set(SERVING_CLIENT_PYTHON_PACKAGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/dist/)
G
guru4elephant 已提交
68
set(SERVING_SERVER_PYTHON_PACKAGE_DIR ${CMAKE_CURRENT_BINARY_DIR}/dist/)
G
guru4elephant 已提交
69

G
guru4elephant 已提交
70
if (CLIENT_ONLY)
G
guru4elephant 已提交
71 72 73
install(DIRECTORY ${SERVING_CLIENT_PYTHON_PACKAGE_DIR}
    DESTINATION opt/serving_client/share/wheels
)
G
guru4elephant 已提交
74 75 76 77 78 79 80
endif()

if (NOT CLIENT_ONLY)
install(DIRECTORY ${SERVING_SERVER_PYTHON_PACKAGE_DIR}
    DESTINATION opt/serving_server/share/wheels
)
endif()
G
guru4elephant 已提交
81 82 83 84 85 86

find_program(PATCHELF_EXECUTABLE patchelf)
if(NOT PATCHELF_EXECUTABLE)
  message(FATAL_ERROR "patchelf not found, please install it.\n"
         "For Ubuntu, the command is: apt-get install -y patchelf.")
endif()