Skip to content

Commit

Permalink
Merge pull request #3745 from quantumsteve/python3_executable
Browse files Browse the repository at this point in the history
Use ${Python3_EXECUTABLE} instead of shebang on top of Python files
  • Loading branch information
ye-luo authored Jan 22, 2022
2 parents f555a31 + 64d9f4b commit db42f59
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions CMake/macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ else(QMC_NO_SLOW_CUSTOM_TESTING_COMMANDS)
#MESSAGE("check command = ${CHECK_CMD}")
add_test(
NAME ${TEST_NAME}
COMMAND ${CHECK_CMD}
COMMAND ${Python3_EXECUTABLE} ${CHECK_CMD}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${FULL_NAME}")
set_property(TEST ${TEST_NAME} APPEND PROPERTY DEPENDS ${FULL_NAME})
set_property(TEST ${TEST_NAME} APPEND PROPERTY LABELS "QMCPACK-checking-results")
Expand Down Expand Up @@ -536,7 +536,7 @@ else(QMC_NO_SLOW_CUSTOM_TESTING_COMMANDS)
${SCALAR_ERROR})
add_test(
NAME ${TEST_NAME}
COMMAND ${CHECK_CMD}
COMMAND ${Python3_EXECUTABLE} ${CHECK_CMD}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${FULL_NAME}")
set_property(TEST ${TEST_NAME} APPEND PROPERTY DEPENDS ${FULL_NAME})
set_property(TEST ${TEST_NAME} APPEND PROPERTY LABELS "QMCPACK-checking-results")
Expand Down Expand Up @@ -595,7 +595,7 @@ else(QMC_NO_SLOW_CUSTOM_TESTING_COMMANDS)

add_test(
NAME "${test_name}"
COMMAND ${check_cmd} ${ARGN}
COMMAND ${Python3_EXECUTABLE} ${check_cmd} ${ARGN}
WORKING_DIRECTORY "${work_dir}")

# make test depend on the run
Expand Down
2 changes: 1 addition & 1 deletion CMake/test_labels.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function(ADD_TEST_LABELS TEST_NAME TEST_LABELS)
else()
set(SUCCESS FALSE)
execute_process(
COMMAND ${qmcpack_SOURCE_DIR}/tests/scripts/test_labels.py ${TEST_NAME} ${QMC_CUDA} ${QMC_COMPLEX}
COMMAND ${Python3_EXECUTABLE} ${qmcpack_SOURCE_DIR}/tests/scripts/test_labels.py ${TEST_NAME} ${QMC_CUDA} ${QMC_COMPLEX}
${QMC_MIXED_PRECISION}
OUTPUT_VARIABLE TEST_LABELS_TEMP
RESULT_VARIABLE SUCCESS)
Expand Down
10 changes: 5 additions & 5 deletions tests/afqmc/workflow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function(ADD_AFQMC_PYSCF_WORKFLOW_TEST test_name input_dir TEST_SCALARS TEST_OBS
set(TESTNAME "converter_test_pyscf_${test_name}")
add_test(
NAME ${TESTNAME}
COMMAND ${TESTDIR}/scf.py gen_test_data
COMMAND ${Python3_EXECUTABLE} ${TESTDIR}/scf.py gen_test_data
WORKING_DIRECTORY ${TESTDIR})
set_property(
TEST ${TESTNAME}
Expand All @@ -23,7 +23,7 @@ function(ADD_AFQMC_PYSCF_WORKFLOW_TEST test_name input_dir TEST_SCALARS TEST_OBS
add_test(
NAME ${TESTNAME}
COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${NPROC_INT} ${MPIEXEC_PREFLAGS}
${PROJECT_SOURCE_DIR}/utils/afqmctools/bin/pyscf_to_afqmc.py ${ARGN}
${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/utils/afqmctools/bin/pyscf_to_afqmc.py ${ARGN}
WORKING_DIRECTORY ${TESTDIR})
set_tests_properties(${TESTNAME} PROPERTIES DEPENDS "converter_test_pyscf_${test_name}")
set_property(TEST ${TESTNAME} APPEND PROPERTY LABELS "converter;afqmc")
Expand All @@ -32,7 +32,7 @@ function(ADD_AFQMC_PYSCF_WORKFLOW_TEST test_name input_dir TEST_SCALARS TEST_OBS
set(TESTNAME "converter_test_hamiltonian_consistency_${test_name}")
add_test(
NAME ${TESTNAME}
COMMAND ${PROJECT_SOURCE_DIR}/utils/afqmctools/bin/test_afqmc_input.py --input afqmc.h5
COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/utils/afqmctools/bin/test_afqmc_input.py --input afqmc.h5
WORKING_DIRECTORY ${TESTDIR})
set_tests_properties(${TESTNAME} PROPERTIES DEPENDS "converter_test_pyscf_to_afqmc_${test_name}")
set_property(TEST ${TESTNAME} APPEND PROPERTY LABELS "converter;afqmc")
Expand All @@ -41,7 +41,7 @@ function(ADD_AFQMC_PYSCF_WORKFLOW_TEST test_name input_dir TEST_SCALARS TEST_OBS
set(TESTNAME "converter_test_gen_input_${test_name}")
add_test(
NAME ${TESTNAME}
COMMAND "${TESTDIR}/gen_input.py"
COMMAND ${Python3_EXECUTABLE} ${TESTDIR}/gen_input.py
WORKING_DIRECTORY ${TESTDIR})
set_tests_properties(${TESTNAME} PROPERTIES DEPENDS "converter_test_hamiltonian_consistency_${test_name}")
set_property(TEST ${TESTNAME} APPEND PROPERTY LABELS "converter;afqmc")
Expand All @@ -64,7 +64,7 @@ function(ADD_AFQMC_PYSCF_WORKFLOW_TEST test_name input_dir TEST_SCALARS TEST_OBS
set(TESTNAME "converter_test_qmcpack_obs_${test_name}")
add_test(
NAME ${TESTNAME}
COMMAND ${TESTDIR}/reference/test_obs.py
COMMAND ${Python3_EXECUTABLE} ${TESTDIR}/reference/test_obs.py
WORKING_DIRECTORY ${TESTDIR})
set_tests_properties(${TESTNAME} PROPERTIES DEPENDS "converter_test_qmcpack_${test_name}-16-1")
set_property(TEST ${TESTNAME} APPEND PROPERTY LABELS "converter;afqmc")
Expand Down
4 changes: 2 additions & 2 deletions tests/converter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function(ADD_CONVERTER_TEST test_name)
string(REPLACE ";" " " EXE_NAME "${EXE_NAME}")
endif()
add_test(NAME converter_${test_name}
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/converter_test.py" "${CMAKE_CURRENT_BINARY_DIR}/${test_name}" --exe
COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/converter_test.py" "${CMAKE_CURRENT_BINARY_DIR}/${test_name}" --exe
"${EXE_NAME}" --h5diff "${HDF5_DIFF_EXECUTABLE}")
set_tests_properties(converter_${test_name} PROPERTIES
FAIL_REGULAR_EXPRESSION " FAIL"
Expand All @@ -25,7 +25,7 @@ function(ADD_PWCONVERTER_TEST test_name)
"${CMAKE_CURRENT_BINARY_DIR}/${test_name}")
set(EXE_NAME $<TARGET_FILE:convertpw4qmc>)
add_test(NAME converter_${test_name}
COMMAND "${CMAKE_CURRENT_BINARY_DIR}/pwconverter_test.py" "${CMAKE_CURRENT_BINARY_DIR}/${test_name}" --exe
COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/pwconverter_test.py" "${CMAKE_CURRENT_BINARY_DIR}/${test_name}" --exe
"${EXE_NAME}" --h5diff "${HDF5_DIFF_EXECUTABLE}")
set_tests_properties(converter_${test_name} PROPERTIES
FAIL_REGULAR_EXPRESSION " FAIL"
Expand Down
2 changes: 1 addition & 1 deletion tests/molecules/He_param/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if(NOT QMC_CUDA)
# but we need to write a file there before that runs
set(TDIR "${CMAKE_CURRENT_BINARY_DIR}/He_param_grad_load-1-16")
file(MAKE_DIRECTORY ${TDIR})
execute_process(COMMAND ${qmcpack_SOURCE_DIR}/tests/molecules/He_param/convert_vp_format.py ${SDIR}/he_vp_opt.txt ${complex_flag} -o ${TDIR}/he_vp_opt.h5)
execute_process(COMMAND ${Python3_EXECUTABLE} ${qmcpack_SOURCE_DIR}/tests/molecules/He_param/convert_vp_format.py ${SDIR}/he_vp_opt.txt ${complex_flag} -o ${TDIR}/he_vp_opt.h5)

list(APPEND HE_BSPLINE_OPT_PARAM jud_0 0.00000124 0.0014) # scalar name, value, error
list(APPEND HE_BSPLINE_OPT_PARAM jud_1 -0.000273 0.00097)
Expand Down
2 changes: 1 addition & 1 deletion tests/performance/C-graphite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function(ADD_C_GRAPHITE_TEST TEST_NAME TEST_DIR INPUT_FILE H5_FILE)
set_tests_properties(${TEST_NAME} PROPERTIES PROCESSORS ${TOT_PROCS} PROCESSOR_AFFINITY TRUE)

if(ENABLE_TIMERS)
add_test(NAME "${TEST_NAME}-time" COMMAND ../process_perf.py ${INPUT_FILE})
add_test(NAME "${TEST_NAME}-time" COMMAND ${Python3_EXECUTABLE} ../process_perf.py ${INPUT_FILE})
set_tests_properties("${TEST_NAME}-time" PROPERTIES LABELS "performance")
set_tests_properties("${TEST_NAME}-time" PROPERTIES WORKING_DIRECTORY "${WDIR}")
set_tests_properties("${TEST_NAME}-time" PROPERTIES DEPENDS ${TEST_NAME})
Expand Down
4 changes: 2 additions & 2 deletions tests/performance/C-molecule/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if(NOT QMC_CUDA)

separate_arguments(ADJUST_INPUT)
execute_process(
COMMAND ${qmcpack_SOURCE_DIR}/tests/performance/adjust_qmcpack_input.py ${ADJUST_INPUT}
COMMAND ${Python3_EXECUTABLE} ${qmcpack_SOURCE_DIR}/tests/performance/adjust_qmcpack_input.py ${ADJUST_INPUT}
${TEST_DIR}/${INPUT_FILE} WORKING_DIRECTORY "${qmcpack_BINARY_DIR}/tests/performance/C-molecule")

set(PROCS 1)
Expand All @@ -55,7 +55,7 @@ if(NOT QMC_CUDA)
set_tests_properties(${TEST_NAME} PROPERTIES PROCESSORS ${TOT_PROCS} PROCESSOR_AFFINITY TRUE)

if(ENABLE_TIMERS)
add_test(NAME "${TEST_NAME}-time" COMMAND ../process_perf.py ${INPUT_FILE})
add_test(NAME "${TEST_NAME}-time" COMMAND ${Python3_EXECUTABLE} ../process_perf.py ${INPUT_FILE})
set_tests_properties("${TEST_NAME}-time" PROPERTIES LABELS "performance")
set_tests_properties("${TEST_NAME}-time" PROPERTIES WORKING_DIRECTORY "${WDIR}")
set_tests_properties("${TEST_NAME}-time" PROPERTIES DEPENDS ${TEST_NAME})
Expand Down
4 changes: 2 additions & 2 deletions tests/performance/NiO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function(
maybe_symlink("${QMC_DATA}/NiO/${H5_FILE}" "${WDIR}/../${H5_FILE}")

separate_arguments(ADJUST_INPUT)
execute_process(COMMAND ${qmcpack_SOURCE_DIR}/tests/performance/adjust_qmcpack_input.py ${ADJUST_INPUT}
execute_process(COMMAND ${Python3_EXECUTABLE} ${qmcpack_SOURCE_DIR}/tests/performance/adjust_qmcpack_input.py ${ADJUST_INPUT}
${TEST_DIR}/${INPUT_FILE} WORKING_DIRECTORY "${qmcpack_BINARY_DIR}/tests/performance/NiO")

set(TEST_NAME ${TEST_NAME}-${PROCS}-${THREADS})
Expand All @@ -57,7 +57,7 @@ function(
endif()

if(ENABLE_TIMERS)
add_test(NAME "${TEST_NAME}-time" COMMAND ../process_perf.py ${INPUT_FILE})
add_test(NAME "${TEST_NAME}-time" COMMAND ${Python3_EXECUTABLE} ../process_perf.py ${INPUT_FILE})
set_tests_properties("${TEST_NAME}-time" PROPERTIES LABELS "performance")
set_tests_properties("${TEST_NAME}-time" PROPERTIES WORKING_DIRECTORY "${WDIR}")
set_tests_properties("${TEST_NAME}-time" PROPERTIES DEPENDS ${TEST_NAME})
Expand Down

0 comments on commit db42f59

Please sign in to comment.