Skip to content

Commit 77b19b1

Browse files
committed
fix: return the original python executable if resolve_symlink=True
Signed-off-by: Frost Ming <me@frostming.com>
1 parent 1b7b466 commit 77b19b1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/findpython/finder.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import dataclasses
34
import logging
45
import operator
56
from typing import Callable, Iterable
@@ -184,8 +185,6 @@ def dedup_key(python_version: PythonVersion) -> str:
184185
return python_version.interpreter.as_posix()
185186
if self.no_same_file:
186187
return python_version.binary_hash()
187-
if self.resolve_symlinks and not python_version.keep_symlink:
188-
return python_version.real_path.as_posix()
189188
return python_version.executable.as_posix()
190189

191190
def sort_key(python_version: PythonVersion) -> tuple[int, int, int]:
@@ -198,6 +197,14 @@ def sort_key(python_version: PythonVersion) -> tuple[int, int, int]:
198197
result: dict[str, PythonVersion] = {}
199198

200199
for python_version in sorted(python_versions, key=sort_key):
200+
if (
201+
self.resolve_symlinks
202+
and not python_version.keep_symlink
203+
and python_version.executable.is_symlink()
204+
):
205+
python_version = dataclasses.replace(
206+
python_version, executable=python_version.real_path
207+
)
201208
key = dedup_key(python_version)
202209
if (
203210
key not in result

0 commit comments

Comments
 (0)