From cfce3f5ea00bf88947be55f7f12189b9dd3aae78 Mon Sep 17 00:00:00 2001
From: Brent Huisman <brenthuisman@users.noreply.github.com>
Date: Mon, 4 Jan 2021 11:17:21 +0100
Subject: [PATCH] Fix CMake to use correct PYTHON_EXECUTABLE (#1290)

Fix CMAKE to use PYTHON_EXECUTABLE that corresponds to the version of Python used to build the python module.
---
 CMakeLists.txt        | 9 ---------
 python/CMakeLists.txt | 5 +++++
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a0fcc96d..6ecf73b0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -59,15 +59,6 @@ option(ARB_WITH_NEUROML "build NeuroML support library" OFF)
 
 option(ARB_WITH_PYTHON "enable Python front end" OFF)
 
-if (ARB_WITH_PYTHON)
-    # Find path in which to install the Python module.
-    find_package(PythonInterp REQUIRED)
-    # Ask the above found Python where it keeps its system (platform) packages.
-    execute_process (COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; print(sysconfig.get_path('platlib'))" OUTPUT_VARIABLE ARB_PYTHON_LIB_PATH_DEFAULT OUTPUT_STRIP_TRAILING_WHITESPACE)
-    # Default to installing in that path
-    set(ARB_PYTHON_LIB_PATH ${ARB_PYTHON_LIB_PATH_DEFAULT} CACHE PATH "path for installing Python module for Arbor.")
-endif()
-
 #----------------------------------------------------------
 # Global CMake configuration
 #----------------------------------------------------------
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index dd31c7a9..f20ffe2d 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -75,4 +75,9 @@ file(COPY "${PROJECT_SOURCE_DIR}/VERSION" DESTINATION "${python_mod_path}")
 
 # Set the installation path
 
+# Ask Python where it keeps its system (platform) packages.
+execute_process (COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig; print(sysconfig.get_path('platlib'))" OUTPUT_VARIABLE ARB_PYTHON_LIB_PATH_DEFAULT OUTPUT_STRIP_TRAILING_WHITESPACE)
+# Default to installing in that path, override with user specified ARB_PYTHON_LIB_PATH
+set(ARB_PYTHON_LIB_PATH ${ARB_PYTHON_LIB_PATH_DEFAULT} CACHE PATH "path for installing Python module for Arbor.")
+
 install(DIRECTORY ${python_mod_path} DESTINATION ${ARB_PYTHON_LIB_PATH})
-- 
GitLab