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
This feature automatically refreshes the package list when packages are installed or uninstalled in Python environments. It works by monitoring the `site-packages` directory for changes and triggering the package manager's refresh functionality when changes are detected.
3
+
This feature automatically refreshes the package list when packages are installed or uninstalled in Python environments. It works by monitoring each environment's package directory for changes and triggering the package manager's refresh functionality when changes are detected.
4
4
5
5
## How It Works
6
6
7
-
1.**Environment Monitoring**: The `SitePackagesWatcherService` listens for environment changes (add/remove)
8
-
2.**Site-packages Resolution**: For each environment, the service resolves the site-packages path using the environment's `sysPrefix`
9
-
3.**File System Watching**: Creates VS Code file system watchers to monitor the site-packages directories
7
+
1.**Environment Setup**: Each environment specifies its package directory via the `packageFolder` property
8
+
2.**Environment Monitoring**: The `SitePackagesWatcherService` listens for environment changes (add/remove)
9
+
3.**File System Watching**: Creates VS Code file system watchers to monitor the package directories
10
10
4.**Automatic Refresh**: When changes are detected, triggers the appropriate package manager's `refresh()` method
11
11
12
12
## Supported Environment Types
13
13
14
-
The feature works with all environment types that provide a valid `sysPrefix`:
14
+
The feature works with all environment types that set the `packageFolder` property:
15
15
16
16
-**venv** environments
17
17
-**conda** environments
18
18
-**system** Python installations
19
19
-**poetry** environments
20
20
-**pyenv** environments
21
21
22
-
## Site-packages Path Resolution
22
+
## Package Directory Resolution
23
23
24
-
The service automatically detects site-packages directories on different platforms:
24
+
Each environment manager is responsible for setting the `packageFolder` property when creating environments. The resolution follows platform-specific patterns:
Environment managers use the `resolvePackageFolderFromSysPrefix()` utility function to determine the appropriate package directory based on the environment's `sysPrefix`.
35
36
36
37
## Implementation Details
37
38
38
39
### Key Components
39
40
40
41
1.**`SitePackagesWatcherService`**: Main service that manages file system watchers
41
-
2.**`sitePackagesUtils.ts`**: Utility functions for resolving site-packages paths
42
-
3.**Integration**: Automatically initialized in `extension.ts` when the extension activates
42
+
2.**`sitePackagesUtils.ts`**: Utility function for resolving package folder paths from sysPrefix
43
+
3.**Environment Managers**: Each manager sets the `packageFolder` property when creating environments
44
+
4.**Integration**: Automatically initialized in `extension.ts` when the extension activates
43
45
44
46
### Lifecycle Management
45
47
@@ -49,9 +51,9 @@ The service automatically detects site-packages directories on different platfor
49
51
50
52
### Error Handling
51
53
52
-
- Graceful handling of environments without valid `sysPrefix`
54
+
- Graceful handling of environments without a `packageFolder` property
53
55
- Robust error handling for file system operations
54
-
- Fallback behavior when site-packages directories cannot be found
56
+
- Fallback behavior when package directories cannot be accessed
55
57
56
58
## Benefits
57
59
@@ -60,10 +62,29 @@ The service automatically detects site-packages directories on different platfor
60
62
3.**Environment Agnostic**: Supports all Python environment types
61
63
4.**Performance**: Uses VS Code's efficient file system watchers
62
64
5.**User Experience**: No manual refresh needed after installing/uninstalling packages
65
+
6.**Simplified Architecture**: Environment managers explicitly specify their package directories
63
66
64
67
## Technical Notes
65
68
66
69
- File system events are debounced to avoid excessive refresh calls
67
70
- Package refreshes happen asynchronously to avoid blocking the UI
68
71
- The service integrates seamlessly with existing package manager architecture
69
-
- Comprehensive test coverage ensures reliability across different scenarios
72
+
- Environment managers use the `resolvePackageFolderFromSysPrefix()` utility for consistent package directory resolution
73
+
- Comprehensive test coverage ensures reliability across different scenarios
74
+
75
+
## For Environment Manager Developers
76
+
77
+
When implementing a new environment manager, ensure you set the `packageFolder` property in your `PythonEnvironmentInfo`:
0 commit comments