-
Notifications
You must be signed in to change notification settings - Fork 36
Add python-env.globalSearchPaths and workspaceSearchPaths settings for custom Python environment discovery with legacy Python settings migration #822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
|
@copilot here are some notes and updates you should make:
|
…utable paths support, improve logging, refactor configure function Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
I've implemented all the requested changes in commit c885a3b:
The implementation now properly handles settings precedence and migration while providing detailed logging throughout the process. |
eleanorjboyd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot address these comments
…code organization Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
eleanorjboyd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot address my comments
…ettings Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
|
@copilot I have a few changes to the design I need you to implement in code:
|
|
@copilot try and implement those changes I just sent again |
…rkspaceSearchPaths Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
Implemented all the requested design changes in commit dec6c96:
The implementation properly handles VS Code settings precedence and scope restrictions while maintaining backward compatibility. All tests continue to pass. |
9348041 to
43492da
Compare
| */ | ||
| function extractEnvironmentDirectory(executablePath: string): string | undefined { | ||
| try { | ||
| // TODO: This logic may need to be adjusted for Windows paths (esp with Conda as doesn't use Scripts folder?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you have advice here @karthiknadig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, when you have the executable path you can use resolve from native locator to get the actual environment path.
| if (isRegexPattern) { | ||
| // Search for Python executables using the regex pattern | ||
| // Look for common Python executable names within the pattern | ||
| const pythonExecutablePatterns = isWindows() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this search design make sense to you @karthiknadig
|
went a different direction and implemented these in an MVP in another PR |
This PR implements two new settings that allow users to specify additional locations for Python environment discovery and automatically migrates from legacy Python settings. The implementation provides separate settings for different use cases:
Features
1. Global Search Paths (
python-env.globalSearchPaths)Users can specify absolute directory paths for global environment locations:
{ "python-env.globalSearchPaths": ["/home/user/.pyenv/versions", "C:\\Users\\user\\envs"] }2. Workspace Search Paths (
python-env.workspaceSearchPaths)Users can specify relative paths or regex patterns for workspace-specific discovery:
{ "python-env.workspaceSearchPaths": ["**/bin/python*", "**/.venv/bin/python", "./envs"] }Implementation Details
getAllExtraSearchPaths()function integrating both settingsextractEnvironmentDirectory()function with improved error logging for invalid folder structuresConfiguration
Both settings are available in VS Code settings with appropriate scope restrictions:
{ "python-env.globalSearchPaths": [], "python-env.workspaceSearchPaths": [] }Migration from Legacy Python Settings
The extension automatically handles migration from legacy Python settings without removing the original settings:
python.venvPath,python.venvFoldersat user level) →globalSearchPathspython.venvPath,python.venvFoldersat workspace level) →workspaceSearchPathsTesting
Fixes #821.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.