Skip to content

Commit

Permalink
Raise "missed venv" exception only when compatible Pythons are not …
Browse files Browse the repository at this point in the history
…found
  • Loading branch information
ivankravets committed Jul 28, 2023
1 parent dcc7464 commit ed3224c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion get-platformio.py

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions pioinstaller/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def find_compatible_pythons(
candidates.insert(0, sys.executable)

result = []
missed_venv_module = False
for item in candidates:
if item in ignore_list:
continue
Expand All @@ -224,26 +225,29 @@ def find_compatible_pythons(
except UnicodeDecodeError:
pass
except subprocess.CalledProcessError as e:
error = None
try:
error = e.output.decode()
if error and "`venv` module" in error:
missed_venv_module = True
log.debug(error)
except UnicodeDecodeError:
pass
if error and "`venv` module" in error:
# pylint:disable=line-too-long
raise click.ClickException(
"""Can not install PlatformIO Core due to a missed `venv` module in your Python installation.
Please install this package manually using the OS package manager. For example:
$ apt-get install python3-venv
(MAY require administrator access `sudo`)""",
)
except Exception as e: # pylint: disable=broad-except
log.debug(e)

if not result and raise_exception:
if missed_venv_module:
# pylint:disable=line-too-long
raise click.ClickException(
"""Can not install PlatformIO Core due to a missed `venv` module in your Python installation.
Please install this package manually using the OS package manager. For example:
$ apt-get install python3.%d-venv
(MAY require administrator access `sudo`)"""
% (sys.version_info[1]),
)

raise exception.IncompatiblePythonError(
"Could not find compatible Python 3.6 or above in your system."
"Please install the latest official Python 3 and restart installation:\n"
Expand Down

0 comments on commit ed3224c

Please sign in to comment.