diff --git a/back/config/util.ts b/back/config/util.ts index e6a77219..dc6fd26c 100644 --- a/back/config/util.ts +++ b/back/config/util.ts @@ -517,15 +517,22 @@ 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 "exec(''' +name='${name}' +try: + from importlib.metadata import version + print(version(name)) +except: + import importlib.util as u + import importlib.metadata as m + spec=u.find_spec(name) + print(name if spec else '') +''')"`, [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 {