Skip to content

Commit

Permalink
Ensure system Python has the highest priority
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Jul 28, 2023
1 parent 6ffb731 commit dcc7464
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pioinstaller/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ def find_compatible_pythons(
for p in ignore_pythons or []:
ignore_list.extend(glob.glob(p))
exenames = [
# "python3.11",
"python3", # system Python
"python3.11",
"python3.10",
"python3.9",
"python3.8",
"python3.7",
"python3",
"python",
]
if util.IS_WINDOWS:
Expand All @@ -196,8 +196,12 @@ def find_compatible_pythons(
if not os.path.isfile(os.path.join(path, exe)):
continue
candidates.append(os.path.join(path, exe))
if sys.executable not in candidates:
candidates.insert(0, sys.executable)

if sys.executable in candidates:
candidates.remove(sys.executable)
# put current Python to the top of list
candidates.insert(0, sys.executable)

result = []
for item in candidates:
if item in ignore_list:
Expand Down

0 comments on commit dcc7464

Please sign in to comment.