Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce reinstall times #304

Merged
merged 4 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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