From 0ff60f8cf837c95b90839ac7c4ce51c88afd2379 Mon Sep 17 00:00:00 2001 From: whyour Date: Fri, 23 May 2025 01:14:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BE=9D=E8=B5=96=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=AE=89=E8=A3=85=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/config/util.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/back/config/util.ts b/back/config/util.ts index e6a77219..14771da0 100644 --- a/back/config/util.ts +++ b/back/config/util.ts @@ -517,15 +517,11 @@ export async function setSystemTimezone(timezone: string): Promise { export function getGetCommand(type: DependenceTypes, name: string): string { const baseCommands = { [DependenceTypes.nodejs]: `pnpm ls -g | grep "${name}" | head -1`, - [DependenceTypes.python3]: `python3 -c "import importlib;pkg=importlib.import_module('${name}');print(getattr(pkg, '__version__', 'inner package'))"`, + [DependenceTypes.python3]: `python3 -c "import sys, importlib.util; from importlib.metadata import version, PackageNotFoundError; m=sys.argv[1]; spec=importlib.util.find_spec(m); print(version(m) if spec and 'site-packages' in (spec.origin or '') else (m if spec else ''))" ${name}`, [DependenceTypes.linux]: `apk info -es ${name}`, }; - let command = baseCommands[type]; - - return type === DependenceTypes.python3 - ? command - : `${command} ${name.trim()}`; + return baseCommands[type]; } export function getInstallCommand(type: DependenceTypes, name: string): string {