From 393f1193b66a392526465c72c75a9e02bd34c432 Mon Sep 17 00:00:00 2001 From: Georgiana-Elena Maxim <136567038+gemaxim@users.noreply.github.com> Date: Tue, 19 Dec 2023 11:06:22 +0200 Subject: [PATCH] fix: use correct python command (#230) --- lib/dependencies/inspect-implementation.ts | 24 +++++++++++++++------- test/system/inspect.spec.ts | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/dependencies/inspect-implementation.ts b/lib/dependencies/inspect-implementation.ts index fb7549b6..449eb8b8 100644 --- a/lib/dependencies/inspect-implementation.ts +++ b/lib/dependencies/inspect-implementation.ts @@ -211,13 +211,14 @@ function dumpAllFilesInTempDir(tempDirName: string) { async function updateSetuptools( setuptoolsVersion: string, dir: string, - pythonEnv + pythonEnv, + command: string ) { // For python 3.12, setuptools needs to be updated // due to removal of some deprecated packages // see: https://github.com/pypa/pip/pull/11997 - const pythonVersion = await subProcess.execute(`python`, ['--version'], { + const pythonVersion = await subProcess.execute(command, ['--version'], { cwd: dir, env: pythonEnv, }); @@ -226,10 +227,14 @@ async function updateSetuptools( return; } - await subProcess.execute(`pip install setuptools==${setuptoolsVersion}`, [], { - cwd: dir, - env: pythonEnv, - }); + await subProcess.execute( + `${command} -m pip install setuptools==${setuptoolsVersion}`, + [], + { + cwd: dir, + env: pythonEnv, + } + ); } export async function inspectInstalledDeps( @@ -251,7 +256,12 @@ export async function inspectInstalledDeps( try { const pythonEnv = getPythonEnv(targetFile); - await updateSetuptools(UPDATED_SETUPTOOLS_VERSION, root, pythonEnv); + await updateSetuptools( + UPDATED_SETUPTOOLS_VERSION, + root, + pythonEnv, + command + ); // See ../../pysrc/README.md const output = await subProcess.execute( diff --git a/test/system/inspect.spec.ts b/test/system/inspect.spec.ts index 640bcfae..4b16d1e7 100644 --- a/test/system/inspect.spec.ts +++ b/test/system/inspect.spec.ts @@ -159,7 +159,7 @@ describe('inspect', () => { { pkg: { name: 's3transfer', - version: '0.8.2', + version: '0.9.0', }, directDeps: ['awss'], },