From a2264e40d33e7c78c067924c89c54213e198a08c Mon Sep 17 00:00:00 2001
From: Kitty Barnett <develop@catznip.com>
Date: Sat, 22 Apr 2017 14:54:21 +0200
Subject: [PATCH] Use the current virtualenv's python rather than the system
 default   -> Windows-only

--HG--
branch : Viewer-Build
---
 indra/cmake/Python.cmake | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/indra/cmake/Python.cmake b/indra/cmake/Python.cmake
index a81c9307fc0..1f687f59dbe 100644
--- a/indra/cmake/Python.cmake
+++ b/indra/cmake/Python.cmake
@@ -5,21 +5,30 @@ set(PYTHONINTERP_FOUND)
 if (WINDOWS)
   # On Windows, explicitly avoid Cygwin Python.
 
-  find_program(PYTHON_EXECUTABLE
-    NAMES python25.exe python23.exe python.exe
-    NO_DEFAULT_PATH # added so that cmake does not find cygwin python
-    PATHS
-    [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.7\\InstallPath]
-    [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.6\\InstallPath]
-    [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.5\\InstallPath]
-    [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.4\\InstallPath]
-    [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]
-    [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.7\\InstallPath]
-    [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.6\\InstallPath]
-    [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.5\\InstallPath]
-    [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.4\\InstallPath]
-    [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]
-    )
+  if (DEFINED ENV{VIRTUAL_ENV})
+    find_program(PYTHON_EXECUTABLE
+      NAMES python.exe
+      PATHS
+      "$ENV{VIRTUAL_ENV}\\scripts"
+      NO_DEFAULT_PATH
+      )
+  else()
+    find_program(PYTHON_EXECUTABLE
+      NAMES python25.exe python23.exe python.exe
+      NO_DEFAULT_PATH # added so that cmake does not find cygwin python
+      PATHS
+      [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.7\\InstallPath]
+      [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.6\\InstallPath]
+      [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.5\\InstallPath]
+      [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.4\\InstallPath]
+      [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]
+      [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.7\\InstallPath]
+      [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.6\\InstallPath]
+      [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.5\\InstallPath]
+      [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.4\\InstallPath]
+      [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]
+      )
+  endif()
 elseif (EXISTS /etc/debian_version)
   # On Debian and Ubuntu, avoid Python 2.4 if possible.
 
-- 
GitLab