From cc42ab50d850fe9211abe12f86fdedcfe88d3383 Mon Sep 17 00:00:00 2001 From: Anqi Huang Date: Thu, 28 Aug 2025 17:50:16 -0400 Subject: [PATCH 1/2] test ENOBUF workaround --- packages/pyright-scip/src/virtualenv/environment.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/pyright-scip/src/virtualenv/environment.ts b/packages/pyright-scip/src/virtualenv/environment.ts index 802ba9f8d..eb2fc9204 100644 --- a/packages/pyright-scip/src/virtualenv/environment.ts +++ b/packages/pyright-scip/src/virtualenv/environment.ts @@ -29,13 +29,15 @@ let getPipCommand = () => { }; function pipList(): PipInformation[] { - return JSON.parse(child_process.execSync(`${getPipCommand()} list --format=json`).toString()) as PipInformation[]; + return JSON.parse( + child_process.execSync(`${getPipCommand()} list --format=json`, { maxBuffer: 1024 * 1024 * 5 }).toString() + ) as PipInformation[]; } function pipBulkShow(names: string[]): string[] { // TODO: This probably breaks with enough names. Should batch them into 512 or whatever the max for bash would be return child_process - .execSync(`${getPipCommand()} show -f ${names.join(' ')}`) + .execSync(`${getPipCommand()} show -f ${names.join(' ')}`, { maxBuffer: 1024 * 1024 * 5 }) .toString() .split('\n---'); } From 9b498d5b19f6131b4d0a918bb0c95f847d99f35a Mon Sep 17 00:00:00 2001 From: Anqi77 Date: Fri, 29 Aug 2025 15:14:42 -0400 Subject: [PATCH 2/2] batch pip show inputs --- .../src/virtualenv/environment.ts | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/pyright-scip/src/virtualenv/environment.ts b/packages/pyright-scip/src/virtualenv/environment.ts index eb2fc9204..9f74da28b 100644 --- a/packages/pyright-scip/src/virtualenv/environment.ts +++ b/packages/pyright-scip/src/virtualenv/environment.ts @@ -29,17 +29,28 @@ let getPipCommand = () => { }; function pipList(): PipInformation[] { + console.log(`Executing pip list.`); return JSON.parse( - child_process.execSync(`${getPipCommand()} list --format=json`, { maxBuffer: 1024 * 1024 * 5 }).toString() + child_process.execSync(`${getPipCommand()} list --format=json`, { maxBuffer: 1024 * 1024 * 100 }).toString() ) as PipInformation[]; } function pipBulkShow(names: string[]): string[] { - // TODO: This probably breaks with enough names. Should batch them into 512 or whatever the max for bash would be - return child_process - .execSync(`${getPipCommand()} show -f ${names.join(' ')}`, { maxBuffer: 1024 * 1024 * 5 }) - .toString() - .split('\n---'); + const BATCH_SIZE = 10; + const results: string[] = []; + console.log(names.length + ' packages to show'); + + for (let i = 0; i < names.length; i += BATCH_SIZE) { + const batch = names.slice(i, i + BATCH_SIZE); + console.log(`Executing pip show for the following packages: ${batch.join(', ')}`); + console.log(`${getPipCommand()} show -f ${batch.join(' ')}`);t + const output = child_process + .execSync(`${getPipCommand()} show -f ${batch.join(' ')}`, { maxBuffer: 1024 * 1024 * 5 }) + .toString() + results.push(...output.split('\n---')); + } + + return results; } export default function getEnvironment(