diff --git a/Make.bat b/Make.bat index e95d4434b..97861fce3 100644 --- a/Make.bat +++ b/Make.bat @@ -254,7 +254,7 @@ REM Main build sequence Ends CD "%WD%\runtime" ECHO Running qmake... - CALL "%QMAKE%" || EXIT /B 1 + CALL set "PGADMIN_PYTHON_DIR=%PYTHON_HOME%" && "%QMAKE%" || EXIT /B 1 ECHO Cleaning the build directory... CALL %MAKE% clean || EXIT /B 1 diff --git a/README b/README index b927e2b8c..add6f96e1 100644 --- a/README +++ b/README @@ -26,42 +26,46 @@ Building the Runtime To build the runtime, the following packages must be installed: -- QT 4.6 or above (Use the VC++ build on Windows, not MinGW). +- QT 5 (Use the VC++ build on Windows, not MinGW). - Python 3.4+ -Assuming both qmake and python-config are in the path: +An environment variable named PGADMIN_PYTHON_DIR must be set to the directory +in which Python has been installed, for example: - $ cd $PGADMIN4_SRC/runtime - $ qmake - Project MESSAGE: Building for QT5+... - Project MESSAGE: Building for Linux/Mac... - Project MESSAGE: Using /usr/bin/python-config - Project MESSAGE: Python3 detected. - $ make - ... +- /usr +- /usr/local/python-3.8 +- C:\Python38 -To build the runtime in debug mode, use the option below with qmake +Assuming both qmake is in the path: + + dpage@hal:~/git/pgadmin4$ cd runtime + dpage@hal:~/git/pgadmin4/runtime$ export PGADMIN_PYTHON_DIR=/opt/local + dpage@hal:~/git/pgadmin4/runtime$ qmake + Project MESSAGE: ================================== + Project MESSAGE: Configuring the pgAdmin 4 runtime. + Project MESSAGE: ================================== + Project MESSAGE: Qt version: 5 + Project MESSAGE: Platform: macOS + Project MESSAGE: Python executable: /opt/local/bin/python3 + Project MESSAGE: Python version: 3.8 (38) + Project MESSAGE: Python config: /opt/local/bin/python3-config + Project MESSAGE: CXXFLAGS: -pipe -stdlib=libc++ -I/opt/local/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -I/opt/local/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 + Project MESSAGE: LDFLAGS: -stdlib=libc++ -L/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/config-3.8-darwin -ldl -framework CoreFoundation + Project MESSAGE: LIBS: -lpython3.8 -ldl -framework CoreFoundation + dpage@hal:~/git/pgadmin4/runtime$ make + ... + +To build the runtime in debug mode, use the option below with qmake: $ qmake CONFIG+=debug -To build the runtime in release mode, use the option below with qmake +To build the runtime in release mode, use the option below with qmake: $ qmake CONFIG+=release By default, the runtime application will be built in release mode. -On Linux, an executable called 'pgAdmin4' will be built, and on Mac OS X, an -app bundle called pgAdmin4.app will be created. - -To build the runtime on a Windows system, export PYTHON_HOME and PYTHON_VERSION -variables in the System environment. Specify the PYTHON_VERSION with the major -and minor number. Do not specify micro level version. - -For example, given a Python version of A.B.C; A - Major number, B - Minor -number, C - Micro level (Bug fix releases). - -If Python version is 3.8.2 than specify PYTHON_VERSION=38 - - e.g. PYTHON_HOME=C:\Python38\ - PYTHON_VERSION=38 +On Linux, an executable called 'pgAdmin4' will be built, on Windows, +'pgAdmin4.exe', and on Mac OS X, an app bundle called pgAdmin4.app will be +created. You can also use Qt Creator to build, develop and debug the runtime. Simply open the $PGADMIN4_SRC/runtime/pgAdmin4.pro project file in Qt Creator and @@ -319,7 +323,7 @@ http://www.jrsoftware.org/isdl.php A number of environment variables may need to be set to enable the build script to function. The defaults will usually work on a typical 64 bit system with -Qt 5.5.1, Python 2.7 and Visual Studio 2013. The examples below are for a +Qt 5.14.2, Python 3.8 and Visual Studio 2013. The examples below are for a similar 32 bit system: INNOTOOL=C:\Program Files\Inno Setup 5 @@ -327,8 +331,8 @@ PGDIR=C:\Program Files\PostgreSQL\12 PYTHON_DLL=C:\Python38\Python38.dll PYTHON_HOME=C:\Python38 PYTHON_VERSION=38 -QTDIR=C:\Qt\5.9\msvc2013 -VCDIR=C:\Program Files\Microsoft Visual Studio 12.0\VC +QTDIR=C:\Qt\5.14.2\msvc2015 +VCDIR=C:\Program Files\Microsoft Visual Studio 14.0\VC To build the installer: diff --git a/docs/en_US/release_notes_4_22.rst b/docs/en_US/release_notes_4_22.rst index b17057624..7e44b1ea9 100644 --- a/docs/en_US/release_notes_4_22.rst +++ b/docs/en_US/release_notes_4_22.rst @@ -13,6 +13,7 @@ New features Housekeeping ************ +| `Issue #5444 `_ - Cleanup Python detection in the runtime project file. Bug fixes ********* diff --git a/pkg/linux/build-functions.sh b/pkg/linux/build-functions.sh index baa2dc89b..04e22b373 100644 --- a/pkg/linux/build-functions.sh +++ b/pkg/linux/build-functions.sh @@ -107,9 +107,9 @@ _build_runtime() { make clean fi if hash qmake-qt5 2>/dev/null; then - qmake-qt5 + PGADMIN_PYTHON_DIR=/usr qmake-qt5 else - qmake + PGADMIN_PYTHON_DIR=/usr qmake fi make mkdir -p "${DESKTOPROOT}/usr/${APP_NAME}/bin" diff --git a/pkg/mac/build.sh b/pkg/mac/build.sh index 32e0f4697..258a5246c 100755 --- a/pkg/mac/build.sh +++ b/pkg/mac/build.sh @@ -82,7 +82,7 @@ _cleanup() { rm -f ${DISTROOT}/pgadmin4*.dmg } -_create_python_virtualenv() { +_create_venv() { export PATH=${PGDIR}/bin:${PATH} export LD_LIBRARY_PATH=${PGDIR}/lib:${LD_LIBRARY_PATH} test -d ${BUILDROOT} || mkdir ${BUILDROOT} || exit 1 @@ -147,10 +147,9 @@ _create_python_virtualenv() { } _build_runtime() { - _create_python_virtualenv || exit 1 cd ${SOURCEDIR}/runtime make clean - ${QMAKE} || { echo qmake failed; exit 1; } + PGADMIN_PYTHON_DIR=${PYTHON_HOME} ${QMAKE} || { echo qmake failed; exit 1; } make || { echo make failed; exit 1; } cp -r pgAdmin4.app "${BUILDROOT}/${APP_BUNDLE_NAME}" } @@ -280,6 +279,7 @@ _codesign_dmg() { _get_version || { echo Could not get versioning; exit 1; } _cleanup +_create_venv || { echo venv creation failed; exit 1; } _build_runtime || { echo Runtime build failed; exit 1; } _build_doc _complete_bundle diff --git a/runtime/pgAdmin4.pro b/runtime/pgAdmin4.pro index b041980b2..1e765129f 100644 --- a/runtime/pgAdmin4.pro +++ b/runtime/pgAdmin4.pro @@ -4,12 +4,16 @@ QMAKE_TARGET_PRODUCT = "pgAdmin 4" QMAKE_TARGET_DESCRIPTION = "pgAdmin 4 Desktop Runtime" QMAKE_TARGET_COPYRIGHT = "Copyright (C) 2013 - 2020, The pgAdmin Development Team" +message(==================================) +message(Configuring the pgAdmin 4 runtime.) +message(==================================) + # Configure QT modules for the appropriate version of QT greaterThan(QT_MAJOR_VERSION, 4) { - message(Building for QT5+...) + message(Qt version: 5) QT += network widgets } else { - message(Building for QT4...) + message(Qt version: 4) QT += network DEFINES += Q_NULLPTR=NULL } @@ -22,91 +26,104 @@ QMAKE_CFLAGS += $$(PGADMIN_CFLAGS) QMAKE_CXXFLAGS += $$(PGADMIN_CXXFLAGS) QMAKE_LFLAGS += $$(PGADMIN_LDFLAGS) +# Figure out where/what Python looks like and that it's suitable +PYTHON_DIR = $$(PGADMIN_PYTHON_DIR) + +equals(PYTHON_DIR, "") { + error(The PGADMIN_PYTHON_DIR environment variable is not set. Please set it to a directory path under which Python 3.4 or later has been installed and try again.) +} + win32 { - message(Building for Windows...) - - # Read the PYTHON_HOME and PYTHON_VERSION system environment variables. - PY_HOME = $$(PYTHON_HOME) - PY_VERSION = $$(PYTHON_VERSION) - - lessThan(PY_VERSION, 34) { - error(Python 3.4 or later is required.) + message(Platform: Windows) + PYTHON_EXE = $${PYTHON_DIR}\python.exe +} else { + macx { + message(Platform: macOS) + } else { + message(Platform: Linux) } + PYTHON_EXE = $${PYTHON_DIR}/bin/python3 +} - isEmpty(PY_HOME) { - error(Please define the PYTHON_HOME variable in the system environment.) - } - else { - isEmpty(PY_VERSION) { - error(Please define the PYTHON_VERSION variable in the system environment.) - } - else { - INCLUDEPATH = $$PY_HOME\include - LIBS += -L"$$PY_HOME\libs" -lpython$$PY_VERSION - } - } +!exists($$PYTHON_EXE) { + error(The Python executable ($$PYTHON_EXE) could not be found. Please ensure the PGADMIN_PYTHON_DIR environment variable is correctly set.) +} +message(Python executable: $$PYTHON_EXE) + +PYTHON_VERSION = $$system($$PYTHON_EXE -c \"import sys; print(\'%s.%s\' % (sys.version_info[0], sys.version_info[1]))\") +PYTHON_SHORT_VERSION = $$system($$PYTHON_EXE -c \"import sys; print(\'%s%s\' % (sys.version_info[0], sys.version_info[1]))\") +PYTHON_MAJOR_VERSION = $$system($$PYTHON_EXE -c \"import sys; print(sys.version_info[0])\") +message(Python version: $$PYTHON_VERSION ($$PYTHON_SHORT_VERSION)) + +lessThan(PYTHON_SHORT_VERSION, 34) { + error(Python 3.4 or later is required to build pgAdmin.) +} + +# Configure for the platform +win32 { + INCLUDEPATH = $${PYTHON_DIR}\include + message(Include path: $$INCLUDEPATH) + + LIBS += -L"$${PYTHON_DIR}\libs" -lpython$${PYTHON_SHORT_VERSION} + message(LIBS: $$LIBS) } else { - message(Building for Linux/Mac...) - - # Find and configure Python - # Environment setting - PYTHON_CONFIG = $$(PYTHON_CONFIG) - - # Maybe Python 3? - isEmpty(PYTHON_CONFIG) { - PYTHON_CONFIG = $$system(which python3-config) + # Find the best matching python-config (there may be more than one) + exists($PYTHON_DIR/bin/python$${PYTHON_VERSION}-config) { + PYTHON_CONFIG = $$PYTHON_DIR/bin/python$${PYTHON_VERSION}-config + } else: exists($${PYTHON_DIR}/bin/python$${PYTHON_MAJOR_VERSION}-config) { + PYTHON_CONFIG = $${PYTHON_DIR}/bin/python$${PYTHON_MAJOR_VERSION}-config + } else: exists($${PYTHON_DIR}/bin/python-config) { + PYTHON_CONFIG = $${PYTHON_DIR}/bin/python-config + } else { + error(No suitable python-config could be found in $${PYTHON_DIR}/bin.) } - - # Argh! - isEmpty(PYTHON_CONFIG) { - error(The python3-config executable could not be found. Ensure Python is installed and in the system path.) - } - - message(Using $$PYTHON_CONFIG) + message(Python config: $$PYTHON_CONFIG) PYTHON_EMBED = $$system($$PYTHON_CONFIG --help 2>&1 | grep -o \'\\-\\-embed\') QMAKE_CXXFLAGS += $$system($$PYTHON_CONFIG --includes) - QMAKE_LFLAGS += $$system($$PYTHON_CONFIG --ldflags) - LIBS += $$system($$PYTHON_CONFIG --libs $$PYTHON_EMBED) + message(CXXFLAGS: $$QMAKE_CXXFLAGS) - contains( LIBS, -lpython2.* ) { - error(Building with Python 2 is not supported.) - } else { - message(Building with Python 3.) - } + QMAKE_LFLAGS += $$system($$PYTHON_CONFIG --ldflags) + message(LDFLAGS: $$QMAKE_LFLAGS) + + LIBS += $$system($$PYTHON_CONFIG --libs $$PYTHON_EMBED) + message(LIBS: $$LIBS) } # Source code -HEADERS = Server.h \ - pgAdmin4.h \ - ConfigWindow.h \ - TrayIcon.h \ - LogWindow.h \ - MenuActions.h \ - FloatingWindow.h \ - Logger.h -SOURCES = pgAdmin4.cpp \ - Server.cpp \ - ConfigWindow.cpp \ - TrayIcon.cpp \ - LogWindow.cpp \ - MenuActions.cpp \ - FloatingWindow.cpp \ - Logger.cpp +HEADERS = Server.h \ + pgAdmin4.h \ + ConfigWindow.h \ + TrayIcon.h \ + LogWindow.h \ + MenuActions.h \ + FloatingWindow.h \ + Logger.h -FORMS = ConfigWindow.ui \ - LogWindow.ui \ - FloatingWindow.ui -ICON = pgAdmin4.icns -QMAKE_INFO_PLIST = Info.plist +SOURCES = pgAdmin4.cpp \ + Server.cpp \ + ConfigWindow.cpp \ + TrayIcon.cpp \ + LogWindow.cpp \ + MenuActions.cpp \ + FloatingWindow.cpp \ + Logger.cpp -RESOURCES += pgadmin4.qrc \ - breeze.qrc +FORMS = ConfigWindow.ui \ + LogWindow.ui \ + FloatingWindow.ui + +ICON = pgAdmin4.icns + +QMAKE_INFO_PLIST = Info.plist + +RESOURCES += pgadmin4.qrc \ + breeze.qrc macx { - HEADERS += macos.h - OBJECTIVE_SOURCES = macos.mm + HEADERS += macos.h + OBJECTIVE_SOURCES = macos.mm }