Skip to content

Commit

Permalink
Fix location for native environments
Browse files Browse the repository at this point in the history
  • Loading branch information
karthiknadig committed Jul 23, 2024
1 parent f09ab3f commit 20dbf8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 deletions src/client/pythonEnvironments/nativeAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@ function toArch(a: string | undefined): Architecture {
}
}

function getLocation(nativeEnv: NativeEnvInfo): string {
if (nativeEnv.prefix) {
return nativeEnv.prefix;
}
function getLocation(nativeEnv: NativeEnvInfo, executable: string): string {
if (nativeEnv.executable) {
return nativeEnv.executable;
}
// We should not get here: either prefix or executable should always be available
return '';

if (nativeEnv.prefix) {
return nativeEnv.prefix;
}

return executable;
}

function kindToShortString(kind: PythonEnvKind): string | undefined {
Expand Down Expand Up @@ -172,7 +173,7 @@ function toPythonEnvInfo(nativeEnv: NativeEnvInfo): PythonEnvInfo | undefined {
const executable = nativeEnv.executable ?? makeExecutablePath(nativeEnv.prefix);
return {
name,
location: getLocation(nativeEnv),
location: getLocation(nativeEnv, executable),
kind,
id: executable,
executable: {
Expand Down
4 changes: 2 additions & 2 deletions src/test/pythonEnvironments/nativeAPI.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ suite('Native Python API', () => {
distro: { org: '' },
executable: { filename: '/usr/bin/python', sysPrefix: '/usr/bin', ctime: -1, mtime: -1 },
kind: PythonEnvKind.System,
location: '/usr/bin',
location: '/usr/bin/python',
source: [],
name: 'basic_python',
type: undefined,
Expand Down Expand Up @@ -103,7 +103,7 @@ suite('Native Python API', () => {
mtime: -1,
},
kind: PythonEnvKind.Conda,
location: '/home/user/.conda/envs/conda_python',
location: '/home/user/.conda/envs/conda_python/python',
source: [],
name: 'conda_python',
type: PythonEnvType.Conda,
Expand Down

0 comments on commit 20dbf8a

Please sign in to comment.