Skip to content

Commit 1409db6

Browse files
authored
[LifetimeSafety] Fix Python path for Windows compatibility (#166291)
Fix Python virtual environment paths for Windows in the Lifetime Safety Analysis benchmark ### What changed? - Added conditional path setting for the Python executable in the virtual environment based on the platform - For Windows, use `Scripts/python` path - For other platforms, use `bin/python` path - Updated the commands that use the Python virtual environment to use the platform-specific path ### How to test? `ninja benchmark_lifetime_safety_analysis` Fixes #166143
1 parent 1aa86ca commit 1409db6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

clang/test/Analysis/LifetimeSafety/CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,21 @@ set(LIFETIME_BENCHMARK_REQUIREMENTS
1515
set(LIFETIME_BENCHMARK_OUTPUT_DIR
1616
"${CMAKE_CURRENT_BINARY_DIR}/benchmark_results")
1717

18+
if(WIN32)
19+
set(LIFETIME_BENCHMARK_VENV_PYTHON_EXECUTABLE
20+
"${LIFETIME_BENCHMARK_VENV_DIR}/Scripts/python")
21+
else()
22+
set(LIFETIME_BENCHMARK_VENV_PYTHON_EXECUTABLE
23+
"${LIFETIME_BENCHMARK_VENV_DIR}/bin/python")
24+
endif()
1825

1926
if(EXISTS ${LIFETIME_BENCHMARK_SCRIPT} AND EXISTS ${LIFETIME_BENCHMARK_REQUIREMENTS})
2027

2128
# Set up the virtual environment and install packages
2229
add_custom_command(
2330
OUTPUT ${LIFETIME_BENCHMARK_VENV_DIR}/pyvenv.cfg
2431
COMMAND ${Python3_EXECUTABLE} -m venv ${LIFETIME_BENCHMARK_VENV_DIR}
25-
COMMAND ${LIFETIME_BENCHMARK_VENV_DIR}/bin/python -m pip install -r ${LIFETIME_BENCHMARK_REQUIREMENTS}
32+
COMMAND ${LIFETIME_BENCHMARK_VENV_PYTHON_EXECUTABLE} -m pip install -r ${LIFETIME_BENCHMARK_REQUIREMENTS}
2633
DEPENDS ${LIFETIME_BENCHMARK_REQUIREMENTS}
2734
COMMENT "Creating Python virtual environment and installing dependencies for benchmark..."
2835
)
@@ -32,7 +39,7 @@ if(EXISTS ${LIFETIME_BENCHMARK_SCRIPT} AND EXISTS ${LIFETIME_BENCHMARK_REQUIREME
3239

3340
# Main benchmark target
3441
add_custom_target(benchmark_lifetime_safety_analysis
35-
COMMAND ${LIFETIME_BENCHMARK_VENV_DIR}/bin/python ${LIFETIME_BENCHMARK_SCRIPT}
42+
COMMAND ${LIFETIME_BENCHMARK_VENV_PYTHON_EXECUTABLE} ${LIFETIME_BENCHMARK_SCRIPT}
3643
--clang-binary ${LLVM_BINARY_DIR}/bin/clang
3744
--output-dir ${LIFETIME_BENCHMARK_OUTPUT_DIR}
3845

0 commit comments

Comments
 (0)