Skip to content

Commit ff2ef23

Browse files
committed
fix: activation commands for pyenv
1 parent 1fb10a6 commit ff2ef23

2 files changed

Lines changed: 14 additions & 37 deletions

File tree

src/managers/pyenv/pyenvManager.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -321,24 +321,11 @@ export class PyEnvManager implements EnvironmentManager, Disposable {
321321
return undefined;
322322
}
323323

324-
private getProjectsForEnvironment(environment: PythonEnvironment): PythonProject[] {
325-
return Array.from(this.fsPathToEnv.entries())
326-
.filter(([, env]) => env === environment)
327-
.map(([uri]) => this.api.getPythonProject(Uri.file(uri)))
328-
.filter((project) => project !== undefined) as PythonProject[];
329-
}
330-
331324
private findEnvironmentByPath(fsPath: string): PythonEnvironment | undefined {
332325
const normalized = path.normalize(fsPath);
333326
return this.collection.find((e) => {
334327
const n = path.normalize(e.environmentPath.fsPath);
335328
return n === normalized || path.dirname(n) === normalized || path.dirname(path.dirname(n)) === normalized;
336329
});
337330
}
338-
339-
private findEnvironmentByName(name: string): PythonEnvironment | undefined {
340-
return this.collection.find((e) => {
341-
return e.name === name;
342-
});
343-
}
344331
}

src/managers/pyenv/pyenvUtils.ts

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ import { traceError, traceInfo } from '../../common/logging';
1414
import { getGlobalPersistentState, getWorkspacePersistentState } from '../../common/persistentState';
1515
import { getUserHomeDir, normalizePath, untildify } from '../../common/utils/pathUtils';
1616
import { isWindows } from '../../common/utils/platformUtils';
17-
import { ShellConstants } from '../../features/common/shellConstants';
1817
import {
1918
isNativeEnvInfo,
2019
NativeEnvInfo,
2120
NativeEnvManagerInfo,
2221
NativePythonEnvironmentKind,
2322
NativePythonFinder,
2423
} from '../common/nativePythonFinder';
25-
import { pathForGitBash, shortVersion, sortEnvironments } from '../common/utils';
24+
import { shortVersion, sortEnvironments } from '../common/utils';
2625

2726
async function findPyenv(): Promise<string | undefined> {
2827
try {
@@ -186,15 +185,8 @@ function nativeToPythonEnv(
186185
const shellActivation: Map<string, PythonCommandRunConfiguration[]> = new Map();
187186
const shellDeactivation: Map<string, PythonCommandRunConfiguration[]> = new Map();
188187

189-
shellActivation.set('unknown', [{ executable: pyenv, args: ['shell', name] }]);
190-
shellDeactivation.set('unknown', [{ executable: pyenv, args: ['shell', '--unset'] }]);
191-
192-
if (isWindows()) {
193-
shellActivation.set(ShellConstants.GITBASH, [{ executable: pathForGitBash(pyenv), args: ['shell', name] }]);
194-
shellDeactivation.set(ShellConstants.GITBASH, [
195-
{ executable: pathForGitBash(pyenv), args: ['shell', '--unset'] },
196-
]);
197-
}
188+
shellActivation.set('unknown', [{ executable: 'pyenv', args: ['shell', name] }]);
189+
shellDeactivation.set('unknown', [{ executable: 'pyenv', args: ['shell', '--unset'] }]);
198190

199191
const environment: PythonEnvironmentInfo = {
200192
name: name,
@@ -237,25 +229,23 @@ export async function refreshPyenv(
237229
await setPyenv(pyenv);
238230
}
239231

240-
if (pyenv) {
241-
const envs = data
242-
.filter((e) => isNativeEnvInfo(e))
243-
.map((e) => e as NativeEnvInfo)
244-
.filter((e) => e.kind === NativePythonEnvironmentKind.pyenv);
245-
const collection: PythonEnvironment[] = [];
232+
const envs = data
233+
.filter((e) => isNativeEnvInfo(e))
234+
.map((e) => e as NativeEnvInfo)
235+
.filter((e) => e.kind === NativePythonEnvironmentKind.pyenv);
246236

247-
envs.forEach((e) => {
237+
const collection: PythonEnvironment[] = [];
238+
239+
envs.forEach((e) => {
240+
if (pyenv) {
248241
const environment = nativeToPythonEnv(e, api, manager, pyenv);
249242
if (environment) {
250243
collection.push(environment);
251244
}
252-
});
253-
254-
return sortEnvironments(collection);
255-
}
245+
}
246+
});
256247

257-
traceError('Pyenv not found');
258-
return [];
248+
return sortEnvironments(collection);
259249
}
260250

261251
export async function resolvePyenvPath(

0 commit comments

Comments
 (0)