From 4dc563d71caaf0a76256c6eb2c1e4de6e38de475 Mon Sep 17 00:00:00 2001 From: Dave Page Date: Fri, 17 Jun 2016 09:40:06 +0100 Subject: [PATCH] Fix python detection on Linux/Mac. --- runtime/pgAdmin4.pro | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/runtime/pgAdmin4.pro b/runtime/pgAdmin4.pro index fd3985c02..91f3541c3 100644 --- a/runtime/pgAdmin4.pro +++ b/runtime/pgAdmin4.pro @@ -48,21 +48,32 @@ win32 { else { message(Building for Linux/Mac...) - PYTHON_CONFIG=python3-config - # Find and configure Python - !system(which python3-config > /dev/null 2>&1) { - !system(which python-config > /dev/null 2>&1) { - error(The python-config executable could not be found. Ensure Python is installed and in the system path.) - } else { - PYTHON_CONFIG=python-config - DEFINES += PYTHON2 - } + # Python 3? + PYTHON_CONFIG = $$system(which python3-config) + + # Maybe Python 2? + isEmpty(PYTHON_CONFIG) { + PYTHON_CONFIG = $$system(which python-config) } + # Argh! + isEmpty(PYTHON_CONFIG) { + error(The python-config executable could not be found. Ensure Python is installed and in the system path.) + } + + message(Using $$PYTHON_CONFIG) + QMAKE_CXXFLAGS += $$system($$PYTHON_CONFIG --includes) QMAKE_LFLAGS += $$system($$PYTHON_CONFIG --ldflags) LIBS += $$system($$PYTHON_CONFIG --libs) + + contains( LIBS, -lpython2.* ) { + DEFINES += PYTHON2 + message(Python2 detected.) + } else { + message(Python3 detected.) + } } # Source code