Skip to content

Commit 8f84b7e

Browse files
authored
Merge pull request #304 from LLNL/feature/faster_virtual_env_install
Reduce reinstall times
2 parents 94bc035 + 6ad99d3 commit 8f84b7e

File tree

3 files changed

+37
-16
lines changed

3 files changed

+37
-16
lines changed

cmake/spheral/SpheralAddLibs.cmake

+11-3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ function(spheral_add_obj_library package_name obj_list_name)
4646
# Install the headers
4747
install(FILES ${${package_name}_headers}
4848
DESTINATION include/${package_name})
49+
if(ENABLE_DEV_BUILD)
50+
# Export target name is either spheral_cxx-targets or spheral_llnlcxx-targets
51+
if (${obj_list_name} MATCHES "LLNL")
52+
set(export_target_name spheral_llnlcxx-targets)
53+
else()
54+
set(export_target_name spheral_cxx-targets)
55+
endif()
56+
install(TARGETS Spheral_${package_name}
57+
EXPORT ${export_target_name}
58+
DESTINATION lib)
59+
endif()
4960
# Append Spheral_${package_name} to the global object list
5061
# For example, SPHERAL_OBJ_LIBS or LLNLSPHERAL_OBJ_LIBS
5162
set_property(GLOBAL APPEND PROPERTY ${obj_list_name} Spheral_${package_name})
@@ -85,9 +96,6 @@ function(spheral_add_cxx_library package_name _cxx_obj_list)
8596
set(export_target_name spheral_${lower_case_package}-targets)
8697

8798
if(ENABLE_DEV_BUILD)
88-
install(TARGETS ${_cxx_obj_list}
89-
EXPORT ${export_target_name}
90-
DESTINATION lib)
9199
add_library(Spheral_${package_name} INTERFACE)
92100
target_link_libraries(Spheral_${package_name} INTERFACE ${_cxx_obj_list})
93101
else()

scripts/CMakeLists.txt

+26-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
if (NOT ENABLE_CXXONLY)
22

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

1111
set(SPHERAL_ATS_BUILD_CONFIG_ARGS )
1212

@@ -35,7 +35,7 @@ if (NOT ENABLE_CXXONLY)
3535
endif()
3636

3737
string(REPLACE ";" " " SPHERAL_ATS_BUILD_CONFIG_ARGS_STRING "${SPHERAL_ATS_BUILD_CONFIG_ARGS}")
38-
38+
3939
configure_file(
4040
"${CMAKE_CURRENT_SOURCE_DIR}/spheral-setup-venv.in"
4141
"${CMAKE_CURRENT_BINARY_DIR}/spheral-setup-venv.sh"
@@ -61,7 +61,7 @@ if (NOT ENABLE_CXXONLY)
6161
"${CMAKE_CURRENT_BINARY_DIR}/performance/performance.py"
6262
)
6363

64-
install(FILES
64+
install(FILES
6565
"${CMAKE_CURRENT_BINARY_DIR}/spheral-setup-venv.sh"
6666
"${CMAKE_CURRENT_BINARY_DIR}/spheral-env.sh"
6767
"${CMAKE_CURRENT_BINARY_DIR}/atstest.sh"
@@ -76,6 +76,24 @@ if (NOT ENABLE_CXXONLY)
7676
)
7777

7878
install(CODE "execute_process( \
79-
COMMAND bash ${CMAKE_CURRENT_BINARY_DIR}/spheral-setup-venv.sh \
80-
)")
79+
COMMAND env PYTHONPATH=${SPACK_PYTHONPATH} ${PYTHON_EXE} -m venv .venv --without-pip --prompt \
80+
'Spheral>')"
81+
)
82+
83+
foreach(_venv_dir ${VIRTUALENV_PYTHONPATH_COPY})
84+
if(NOT ${_venv_dir} MATCHES "sphinx")
85+
install(DIRECTORY ${_venv_dir}
86+
USE_SOURCE_PERMISSIONS
87+
MESSAGE_NEVER
88+
DESTINATION "${CMAKE_INSTALL_PREFIX}/.venv"
89+
PATTERN "*\/.spack*" EXCLUDE
90+
PATTERN "*\/tests\/*" EXCLUDE
91+
PATTERN "*.pyc" EXCLUDE
92+
)
93+
endif()
94+
endforeach()
95+
96+
install(CODE "execute_process( \
97+
COMMAND bash ${CMAKE_CURRENT_BINARY_DIR}/spheral-setup-venv.sh)"
98+
)
8199
endif()

scripts/spheral-setup-venv.in

-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
cd @CMAKE_INSTALL_PREFIX@
2-
echo "Creating Spheral virtual python environment ..."
3-
env PYTHONPATH=@SPACK_PYTHONPATH@ @PYTHON_EXE@ -m venv .venv --without-pip --prompt "Spheral>"
4-
5-
echo "Installing runtime python libraries ..."
6-
cp -r @VIRTUALENV_PYTHONPATH_COPY@ .venv/ &> /dev/null
72

83
echo "Setup Spheral libraries ..."
94
cp @SPHERAL_SITE_PACKAGES_PATH@/Spheral.pth .venv/@SPHERAL_SITE_PACKAGES_PATH@/

0 commit comments

Comments
 (0)