@@ -93,15 +93,13 @@ def fetch_portable_python(dst):
9393def check ():
9494 # platform check
9595 if sys .platform == "cygwin" :
96- raise exception .IncompatiblePythonError ("Unsupported cygwin platform" )
96+ raise exception .IncompatiblePythonError ("Unsupported Cygwin platform" )
9797
9898 # version check
99- if not (
100- sys .version_info >= (2 , 7 , 9 ) and sys .version_info < (3 ,)
101- ) and not sys .version_info >= (3 , 5 ):
99+ if sys .version_info < (3 , 6 ):
102100 raise exception .IncompatiblePythonError (
103- "Unsupported python version: %s. "
104- "Supported version: >= 2.7.9 and < 3, or >= 3.5 "
101+ "Unsupported Python version: %s. "
102+ "Minimum supported Python version is 3.6 or above. "
105103 % platform .python_version (),
106104 )
107105
@@ -116,7 +114,7 @@ def check():
116114
117115 # portable Python 3 for macOS is not compatible with macOS < 10.13
118116 # https://github.com/platformio/platformio-core-installer/issues/70
119- if util .IS_MACOS and sys . version_info >= ( 3 , 5 ) :
117+ if util .IS_MACOS :
120118 with tempfile .NamedTemporaryFile () as tmpfile :
121119 os .utime (tmpfile .name )
122120
@@ -142,11 +140,13 @@ def check():
142140 return True
143141
144142
145- def find_compatible_pythons (ignore_pythons = None ): # pylint: disable=too-many-branches
143+ def find_compatible_pythons (
144+ ignore_pythons = None , raise_exception = True
145+ ): # pylint: disable=too-many-branches
146146 ignore_list = []
147147 for p in ignore_pythons or []:
148148 ignore_list .extend (glob .glob (p ))
149- exenames = ["python3" , "python" , "python2" ]
149+ exenames = ["python3" , "python" ]
150150 if util .IS_WINDOWS :
151151 exenames = ["%s.exe" % item for item in exenames ]
152152 log .debug ("Current environment PATH %s" , os .getenv ("PATH" ))
@@ -199,4 +199,12 @@ def find_compatible_pythons(ignore_pythons=None): # pylint: disable=too-many-br
199199
200200(MAY require administrator access `sudo`)""" ,
201201 )
202+
203+ if not result and raise_exception :
204+ raise exception .IncompatiblePythonError (
205+ "Could not find compatible Python 3.6 or above in your system."
206+ "Please install the latest official Python 3 and restart installation:\n "
207+ "https://docs.platformio.org/page/faq.html#install-python-interpreter"
208+ )
209+
202210 return result
0 commit comments