Raise an exception under Python < 3.4.

It also cleans up the README to remove references to Python 2
and removes Python 2-isms from the main config.

refs #5443
This commit is contained in:
Dave Page 2020-04-30 14:17:00 +05:30 committed by Akshay Joshi
parent 109051e1d5
commit 7dd00a1494
4 changed files with 28 additions and 41 deletions

33
README
View File

@ -27,7 +27,7 @@ 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).
- Python 2.7 or 3.4+
- Python 3.4+
Assuming both qmake and python-config are in the path:
@ -36,7 +36,7 @@ Assuming both qmake and python-config are in the path:
Project MESSAGE: Building for QT5+...
Project MESSAGE: Building for Linux/Mac...
Project MESSAGE: Using /usr/bin/python-config
Project MESSAGE: Python2 detected.
Project MESSAGE: Python3 detected.
$ make
...
@ -58,10 +58,10 @@ 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 2.7.12 than specify PYTHON_VERSION=27
If Python version is 3.8.2 than specify PYTHON_VERSION=38
e.g. PYTHON_HOME=C:\Python27\
PYTHON_VERSION=27
e.g. PYTHON_HOME=C:\Python38\
PYTHON_VERSION=38
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
@ -88,10 +88,10 @@ Configuring the Python Environment
----------------------------------
In order to run the Python code, a suitable runtime environment is required.
Python versions - Python 2.7 or 3.4+ are currently supported. It is
recommended that a Python Virtual Environment is setup for this purpose,
rather than using the system Python environment. On Linux and Mac systems, the
process is fairly simple - adapt as required for your distribution:
Python version 3.4 and later are currently supported. It is recommended that a
Python Virtual Environment is setup for this purpose, rather than using the
system Python environment. On Linux and Mac systems, the process is fairly
simple - adapt as required for your distribution:
1) Install the virtualenv packages into the system Python environment
@ -181,11 +181,10 @@ server or desktop mode, and access it from a web browser using the URL shown in
the terminal once pgAdmin has started up.
Setup of an environment on Windows is somewhat more complicated unfortunately,
largely due to the lack of a native compiler toolset. Thankfully, Microsoft
supply a free compiler specifically for Python 2.7 users. Download and install
it from:
largely due to the lack of a native compiler toolset. See the following wiki
page for more information on the compiler you may need:
https://www.microsoft.com/en-gb/download/details.aspx?id=44266
https://wiki.python.org/moin/WindowsCompilers
A blog detailing the setup of Virtual Environments on Windows can be found
here:
@ -324,10 +323,10 @@ Qt 5.5.1, Python 2.7 and Visual Studio 2013. The examples below are for a
similar 32 bit system:
INNOTOOL=C:\Program Files\Inno Setup 5
PGDIR=C:\Program Files\PostgreSQL\10
PYTHON_DLL=C:\Windows\System32\Python27.dll
PYTHON_HOME=C:\Python27
PYTHON_VERSION=27
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

View File

@ -11,15 +11,11 @@
#
##########################################################################
import builtins
import logging
import os
import sys
import json
if sys.version_info[0] >= 3:
import builtins
else:
import __builtin__ as builtins
# We need to include the root directory in sys.path to ensure that we can
# find everything we need when running in the standalone runtime.
@ -27,7 +23,7 @@ root = os.path.dirname(os.path.realpath(__file__))
if sys.path[0] != root:
sys.path.insert(0, root)
from pgadmin.utils import env, IS_PY2, IS_WIN, fs_short_path
from pgadmin.utils import env, IS_WIN, fs_short_path
##########################################################################
# Application settings
@ -566,15 +562,6 @@ try:
except ImportError:
pass
# SUPPORT_SSH_TUNNEL can be override in local config file and if that
# setting is False in local config then we should not check the Python version.
if (SUPPORT_SSH_TUNNEL is True and
((sys.version_info[0] == 2 and sys.version_info[1] < 7) or
(sys.version_info[0] == 3 and sys.version_info[1] < 4))):
SUPPORT_SSH_TUNNEL = False
ALLOW_SAVE_TUNNEL_PASSWORD = False
# Disable USER_INACTIVITY_TIMEOUT when SERVER_MODE=False
if not SERVER_MODE:
USER_INACTIVITY_TIMEOUT = 0

View File

@ -11,13 +11,14 @@
a webserver, this will provide the WSGI interface, otherwise, we're going
to start a web server."""
import os
import sys
if sys.version_info[0] >= 3:
if sys.version_info < (3, 4):
raise Exception('This application must be run under Python 3.4 or later.')
import builtins
else:
import __builtin__ as builtins
import os
# We need to include the root directory in sys.path to ensure that we can
# find everything we need when running in the standalone runtime.

View File

@ -24,10 +24,10 @@ import coverage
import unittest
if sys.version_info[0] >= 3:
if sys.version_info < (3, 4):
raise Exception('The test suite must be run under Python 3.4 or later.')
import builtins
else:
import __builtin__ as builtins
# Ensure the global server mode is set.
builtins.SERVER_MODE = None