You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor pythonfinder for improved efficiency and PEP 514 support
2
+
Summary
3
+
4
+
This PR completely refactors the pythonfinder module to improve efficiency, reduce logical errors, and fix support for PEP 514 (Python registration in the Windows registry). The refactoring replaces the complex object hierarchy with a more modular, composition-based approach that is easier to maintain and extend.
5
+
Motivation
6
+
7
+
The original pythonfinder implementation had several issues:
8
+
9
+
Complex object wrapping with paths as objects, leading to excessive recursion
10
+
Tight coupling between classes making the code difficult to follow and maintain
11
+
Broken Windows registry support (PEP 514)
12
+
Performance issues due to redundant path scanning and inefficient caching
13
+
14
+
Changes
15
+
16
+
Architecture: Replaced inheritance-heavy design with a composition-based approach using specialized finders
17
+
Data Model: Simplified the data model with a clean PythonInfo dataclass
18
+
Windows Support: Implemented proper PEP 514 support for Windows registry
19
+
Performance: Improved caching and reduced redundant operations
20
+
Error Handling: Added more specific exceptions and better error handling
21
+
22
+
Features
23
+
24
+
The refactored implementation continues to support all required features:
25
+
26
+
System and user PATH searches
27
+
pyenv installations
28
+
asdf installations
29
+
Windows registry (PEP 514) - now working correctly
30
+
31
+
Implementation Details
32
+
33
+
The new implementation is organized into three main components:
34
+
35
+
Finders: Specialized classes for finding Python in different locations
36
+
SystemFinder: Searches in the system PATH
37
+
PyenvFinder: Searches in pyenv installations
38
+
AsdfFinder: Searches in asdf installations
39
+
WindowsRegistryFinder: Implements PEP 514 for Windows registry
40
+
41
+
Models: Simple data classes for storing Python information
42
+
PythonInfo: Stores information about a Python installation
43
+
44
+
Utils: Utility functions for path and version handling
0 commit comments