Skip to content

Commit

Permalink
Merge pull request #304 from LLNL/feature/faster_virtual_env_install
Browse files Browse the repository at this point in the history
Reduce reinstall times
  • Loading branch information
ldowen authored Oct 3, 2024
2 parents 94bc035 + 6ad99d3 commit 8f84b7e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 16 deletions.
14 changes: 11 additions & 3 deletions cmake/spheral/SpheralAddLibs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ function(spheral_add_obj_library package_name obj_list_name)
# Install the headers
install(FILES ${${package_name}_headers}
DESTINATION include/${package_name})
if(ENABLE_DEV_BUILD)
# Export target name is either spheral_cxx-targets or spheral_llnlcxx-targets
if (${obj_list_name} MATCHES "LLNL")
set(export_target_name spheral_llnlcxx-targets)
else()
set(export_target_name spheral_cxx-targets)
endif()
install(TARGETS Spheral_${package_name}
EXPORT ${export_target_name}
DESTINATION lib)
endif()
# Append Spheral_${package_name} to the global object list
# For example, SPHERAL_OBJ_LIBS or LLNLSPHERAL_OBJ_LIBS
set_property(GLOBAL APPEND PROPERTY ${obj_list_name} Spheral_${package_name})
Expand Down Expand Up @@ -85,9 +96,6 @@ function(spheral_add_cxx_library package_name _cxx_obj_list)
set(export_target_name spheral_${lower_case_package}-targets)

if(ENABLE_DEV_BUILD)
install(TARGETS ${_cxx_obj_list}
EXPORT ${export_target_name}
DESTINATION lib)
add_library(Spheral_${package_name} INTERFACE)
target_link_libraries(Spheral_${package_name} INTERFACE ${_cxx_obj_list})
else()
Expand Down
34 changes: 26 additions & 8 deletions scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
if (NOT ENABLE_CXXONLY)

# We Use the spack generated build time python path to
# We use the spack generated build time python path to
# pick up all of the python modules needed for our runtime.
# Some modules need to install from directories other that
# site-packages so we strip away site-packages pack and
# Since some modules need to install from directories other than
# site-packages, we strip away site-packages and pack and
# copy the full contents of the python library prefix to
# our virtual env in spheral-setup-venv.sh
string(REGEX REPLACE "lib\/python3.9\/site-packages\/?[A-Za-z]*:" "* " VIRTUALENV_PYTHONPATH_COPY "${SPACK_PYTHONPATH}:")
string(REGEX REPLACE "lib\/python3.9\/site-packages\/?[A-Za-z]*:" ";" VIRTUALENV_PYTHONPATH_COPY "${SPACK_PYTHONPATH}:")

set(SPHERAL_ATS_BUILD_CONFIG_ARGS )

Expand Down Expand Up @@ -35,7 +35,7 @@ if (NOT ENABLE_CXXONLY)
endif()

string(REPLACE ";" " " SPHERAL_ATS_BUILD_CONFIG_ARGS_STRING "${SPHERAL_ATS_BUILD_CONFIG_ARGS}")

configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/spheral-setup-venv.in"
"${CMAKE_CURRENT_BINARY_DIR}/spheral-setup-venv.sh"
Expand All @@ -61,7 +61,7 @@ if (NOT ENABLE_CXXONLY)
"${CMAKE_CURRENT_BINARY_DIR}/performance/performance.py"
)

install(FILES
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/spheral-setup-venv.sh"
"${CMAKE_CURRENT_BINARY_DIR}/spheral-env.sh"
"${CMAKE_CURRENT_BINARY_DIR}/atstest.sh"
Expand All @@ -76,6 +76,24 @@ if (NOT ENABLE_CXXONLY)
)

install(CODE "execute_process( \
COMMAND bash ${CMAKE_CURRENT_BINARY_DIR}/spheral-setup-venv.sh \
)")
COMMAND env PYTHONPATH=${SPACK_PYTHONPATH} ${PYTHON_EXE} -m venv .venv --without-pip --prompt \
'Spheral>')"
)

foreach(_venv_dir ${VIRTUALENV_PYTHONPATH_COPY})
if(NOT ${_venv_dir} MATCHES "sphinx")
install(DIRECTORY ${_venv_dir}
USE_SOURCE_PERMISSIONS
MESSAGE_NEVER
DESTINATION "${CMAKE_INSTALL_PREFIX}/.venv"
PATTERN "*\/.spack*" EXCLUDE
PATTERN "*\/tests\/*" EXCLUDE
PATTERN "*.pyc" EXCLUDE
)
endif()
endforeach()

install(CODE "execute_process( \
COMMAND bash ${CMAKE_CURRENT_BINARY_DIR}/spheral-setup-venv.sh)"
)
endif()
5 changes: 0 additions & 5 deletions scripts/spheral-setup-venv.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
cd @CMAKE_INSTALL_PREFIX@
echo "Creating Spheral virtual python environment ..."
env PYTHONPATH=@SPACK_PYTHONPATH@ @PYTHON_EXE@ -m venv .venv --without-pip --prompt "Spheral>"

echo "Installing runtime python libraries ..."
cp -r @VIRTUALENV_PYTHONPATH_COPY@ .venv/ &> /dev/null

echo "Setup Spheral libraries ..."
cp @SPHERAL_SITE_PACKAGES_PATH@/Spheral.pth .venv/@SPHERAL_SITE_PACKAGES_PATH@/
Expand Down

0 comments on commit 8f84b7e

Please sign in to comment.