Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,35 @@ async function collectEnvironmentInfo(
projectManager: PythonProjectManager
): Promise<string> {
const info: string[] = [];


// Attempt to set setting of config.python.useEnvironmentsExtension to true
try {
const config = workspace.getConfiguration('python');
await config.update('useEnvironmentsExtension', true, true);
} catch (err) {
traceError(
'Failed to set config.python.useEnvironmentsExtension to true. Please do so manually in your user settings now to ensure the Python environment extension is enabled during upcoming experimentation.',
err,
);
}

try {
// Extension version
const extensionVersion = context.extension?.packageJSON?.version || 'unknown';
info.push(`Extension Version: ${extensionVersion}`);

// Python extension version
const pythonExtension = extensions.getExtension('ms-python.python');
const pythonVersion = pythonExtension?.packageJSON?.version || 'not installed';
info.push(`Python Extension Version: ${pythonVersion}`);

// Environment managers
const managers = envManagers.managers;
info.push(`\nRegistered Environment Managers (${managers.length}):`);
managers.forEach(manager => {
managers.forEach((manager) => {
info.push(` - ${manager.id} (${manager.displayName})`);
});

// Available environments
const allEnvironments: PythonEnvironment[] = [];
for (const manager of managers) {
Expand All @@ -106,7 +117,7 @@ async function collectEnvironmentInfo(
info.push(` Error getting environments from ${manager.id}: ${err}`);
}
}

info.push(`\nTotal Available Environments: ${allEnvironments.length}`);
if (allEnvironments.length > 0) {
info.push('Environment Details:');
Expand All @@ -117,7 +128,7 @@ async function collectEnvironmentInfo(
info.push(` ... and ${allEnvironments.length - 10} more environments`);
}
}

// Python projects
const projects = projectManager.getProjects();
info.push(`\nPython Projects (${projects.length}):`);
Expand All @@ -133,18 +144,17 @@ async function collectEnvironmentInfo(
info.push(` Error getting environment: ${err}`);
}
}

// Current settings (non-sensitive)
const config = workspace.getConfiguration('python-envs');
info.push('\nExtension Settings:');
info.push(` Default Environment Manager: ${config.get('defaultEnvManager')}`);
info.push(` Default Package Manager: ${config.get('defaultPackageManager')}`);
info.push(` Terminal Auto Activation: ${config.get('terminal.autoActivationType')}`);

} catch (err) {
info.push(`\nError collecting environment information: ${err}`);
}

return info.join('\n');
}

Expand Down