Skip to content

Commit 9c9d03d

Browse files
committed
refinements
1 parent d01ebb3 commit 9c9d03d

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/managers/builtin/venvUtils.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,17 @@ export async function setVenvForGlobal(envPath: string | undefined): Promise<voi
9898
await state.set(VENV_GLOBAL_KEY, envPath);
9999
}
100100

101-
export async function getPythonInfo(env: NativeEnvInfo): Promise<PythonEnvironmentInfo> {
101+
function getName(binPath: string): string {
102+
const dir1 = path.dirname(binPath);
103+
if (dir1.endsWith('bin') || dir1.endsWith('Scripts') || dir1.endsWith('scripts')) {
104+
return path.basename(path.dirname(dir1));
105+
}
106+
return path.basename(dir1);
107+
}
108+
109+
async function getPythonInfo(env: NativeEnvInfo): Promise<PythonEnvironmentInfo> {
102110
if (env.executable && env.version && env.prefix) {
103-
const venvName = env.name;
111+
const venvName = env.name ?? getName(env.executable);
104112
const sv = shortVersion(env.version);
105113
const name = `${venvName} (${sv})`;
106114

0 commit comments

Comments
 (0)