diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bf54da4fb..e7504d7026 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -439,14 +439,16 @@ if (FF_USE_PYTHON) COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/deps/legion/bindings/python/setup.py build --cmake-build-dir ${Legion_BINARY_DIR}/runtime --prefix ${Legion_BINARY_DIR} --build-lib=${Legion_BINARY_DIR}/bindings/python ${Legion_PYTHON_EXTRA_INSTALL_ARGS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/deps/legion/bindings/python ) - # create flexflow_python interpreter - add_custom_command(TARGET flexflow - PRE_BUILD - COMMAND ${PYTHON_EXECUTABLE} ${FLEXFLOW_ROOT}/python/flexflow_python_build.py --build-dir ${CMAKE_BINARY_DIR} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Creating flexflow_python interpreter..." - ) - install(PROGRAMS ${CMAKE_BINARY_DIR}/flexflow_python DESTINATION "bin") + # create flexflow_python interpreter. When building from pip, we install the FF_HOME/python/flexflow_python script instead. + if (NOT FF_BUILD_FROM_PYPI) + add_custom_command(TARGET flexflow + PRE_BUILD + COMMAND ${PYTHON_EXECUTABLE} ${FLEXFLOW_ROOT}/python/flexflow_python_build.py --build-dir ${CMAKE_BINARY_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Creating flexflow_python interpreter..." + ) + install(PROGRAMS ${CMAKE_BINARY_DIR}/flexflow_python DESTINATION "bin") + endif() endif() # build binary diff --git a/python/flexflow/flexflow_python b/python/flexflow/flexflow_python new file mode 100644 index 0000000000..ac7c5dd827 --- /dev/null +++ b/python/flexflow/flexflow_python @@ -0,0 +1,8 @@ +#! /usr/bin/env bash + +# This file runs the flexflow_python interpreter when installing FlexFlow via pip. This file can be ignored when installing FlexFlow using cmake/make + +python_packages=$(python -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=False,standard_lib=False))") +export PATH="${python_packages}/flexflow/bin:${PATH}" + +legion_python "$@" \ No newline at end of file diff --git a/setup.py b/setup.py index 69c393cbe7..6cc71c718e 100644 --- a/setup.py +++ b/setup.py @@ -39,6 +39,7 @@ "pybind11", "ninja", ], + scripts=['python/flexflow_python'], ext_modules=[ CMakeExtension( name="flexflow",