File tree Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Expand file tree Collapse file tree 2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,27 @@ function(check_deps missing_deps)
40
40
)
41
41
if (NOT (${return_code} EQUAL 0 ))
42
42
list (APPEND local_missing_deps ${package} )
43
+ else ()
44
+ # To make sure CMake import files can be found from venv site packages, we
45
+ # manually add them to CMAKE_PREFIX_PATH
46
+ execute_process (
47
+ COMMAND
48
+ ${Python3_EXECUTABLE} -c
49
+ "import os; import ${package} ; print(os.path.abspath(os.path.dirname(${package} .__file__)))"
50
+ OUTPUT_VARIABLE venv_site_packages_path
51
+ )
52
+ # Remove newlines (\n, \r, \r\n)
53
+ string (REGEX REPLACE "[\r\n ]+$" "" venv_site_packages_path
54
+ "${venv_site_packages_path} "
55
+ )
56
+ if (EXISTS ${venv_site_packages_path} )
57
+ if (NOT (DEFINED CMAKE_PREFIX_PATH ))
58
+ set (CMAKE_PREFIX_PATH "" PARENT_SCOPE )
59
+ endif ()
60
+ set (CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH} ;${venv_site_packages_path} "
61
+ PARENT_SCOPE
62
+ )
63
+ endif ()
43
64
endif ()
44
65
endforeach ()
45
66
Original file line number Diff line number Diff line change @@ -628,16 +628,11 @@ macro(process_options)
628
628
set (Python3_FOUND FALSE )
629
629
set (Python3_INCLUDE_DIRS )
630
630
set (Python3_Interpreter_FOUND FALSE )
631
+ set (Python3_FIND_VIRTUALENV FIRST )
631
632
if (${NS3_PYTHON_BINDINGS} )
632
633
find_package (Python3 COMPONENTS Interpreter Development )
633
634
else ()
634
- # If Python was not set yet, use the version found by check_deps
635
- check_deps (python3_deps EXECUTABLES python3 )
636
- if (python3_deps )
637
- message (FATAL_ERROR "Python3 was not found" )
638
- else ()
639
- set (Python3_EXECUTABLE ${PYTHON3} )
640
- endif ()
635
+ find_package (Python3 COMPONENTS Interpreter )
641
636
endif ()
642
637
643
638
# Check if both Python interpreter and development libraries were found
You can’t perform that action at this time.
0 commit comments