Skip to content

Commit

Permalink
check pt progress (working on power shell, but pyenv thing needs work…
Browse files Browse the repository at this point in the history
… for git bash).
  • Loading branch information
matteius committed May 29, 2024
1 parent d634f1f commit a26d677
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
13 changes: 9 additions & 4 deletions pipenv/vendor/pythonfinder/models/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def _get_last_instance(self, path) -> int:
reversed_paths = reversed(self.path_order)
paths = [resolve_path(p) for p in reversed_paths]
normalized_target = resolve_path(path)
last_instance = next(iter(p for p in paths if normalized_target in p), None)
last_instance = next(iter(p for p in paths if normalized_target == p), None)
if last_instance is None:
raise ValueError(f"No instance found on path for target: {path!s}")
path_index = self.path_order.index(last_instance)
Expand Down Expand Up @@ -263,15 +263,20 @@ def _remove_path(self, path) -> SystemPath:

def _setup_windows_launcher(self) -> SystemPath:
if os.name == "nt":
windows_finder = PythonFinder.create()
windows_finder = PythonFinder.create(
root=Path("."), # Use appropriate root directory for Windows launcher
sort_function=None, # Provide a sorting function if needed
version_glob_path="python*", # Adjust the glob pattern if necessary
ignore_unsupported=True,
)
for launcher_entry in windows_finder.find_python_versions_from_windows_launcher():
version = PythonVersion.from_windows_launcher(launcher_entry)
windows_finder.versions[version.version_tuple] = PathEntry.create(
path_entry = PathEntry.create(
path=launcher_entry.install_path,
is_root=True,
only_python=True,
pythons={launcher_entry.install_path: version},
)
windows_finder._versions[version.version_tuple] = path_entry
self._register_finder("windows", windows_finder)
return self

Expand Down
18 changes: 11 additions & 7 deletions pipenv/vendor/pythonfinder/models/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,18 @@
logger = logging.getLogger(__name__)


@dataclasses.dataclass
class WindowsLauncherEntry:
def __init__(self, version: Version, install_path: str, executable_path: str, company: str, architecture: Optional[str]):
self.version = version
self.install_path = install_path
self.executable_path = executable_path
self.company = company
self.architecture = architecture
version: Version
install_path: str
executable_path: str
windowed_executable_path: str
company: str
architecture: Optional[str]
display_name: Optional[str]
support_url: Optional[str]
tag: Optional[str]



@dataclasses.dataclass
Expand Down Expand Up @@ -162,7 +167,6 @@ def _iter_versions(self) -> Iterator[tuple[Path, PathEntry, tuple]]:
)
yield (base_path, entry, version_tuple)

@cached_property
def versions(self) -> DefaultDict[tuple, PathEntry]:
if not self._versions:
for _, entry, version_tuple in self._iter_versions():
Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/pythonfinder/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def split_version_and_name(


def is_in_path(path, parent):
return resolve_path(str(path)).startswith(resolve_path(str(parent)))
return str(resolve_path(str(path))).startswith(str(resolve_path(str(parent))))


def expand_paths(path, only_python=True) -> Iterator:
Expand Down

0 comments on commit a26d677

Please sign in to comment.