Skip to content

Commit

Permalink
Misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DonJayamanne authored and karthiknadig committed Jul 17, 2024
1 parent b0b74a0 commit 87f4382
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ const untildify = require('untildify');

const PYTHON_ENV_TOOLS_PATH = isWindows()
? path.join(EXTENSION_ROOT_DIR, 'python-env-tools', 'bin', 'pet.exe')
: path.join(EXTENSION_ROOT_DIR, 'python-env-tools', 'bin', 'pet');
: '/Users/donjayamanne/Development/vsc/python-environment-tools/target/debug/pet';

export interface NativeEnvInfo {
displayName?: string;
name?: string;
executable?: string;
kind: string;
kind?: string;
version?: string;
prefix?: string;
manager?: NativeEnvManagerInfo;
Expand Down Expand Up @@ -309,7 +309,6 @@ class NativeGlobalPythonFinderImpl extends DisposableBase implements NativePytho
disposable.add(
this.connection.onNotification('environment', (data: NativeEnvInfo) => {
this.outputChannel.info(`Discovered env: ${data.executable || data.prefix}`);
this.outputChannel.trace(`Discovered env info:\n ${JSON.stringify(data, undefined, 4)}`);
// We know that in the Python extension if either Version of Prefix is not provided by locator
// Then we end up resolving the information.
// Lets do that here,
Expand All @@ -326,7 +325,6 @@ class NativeGlobalPythonFinderImpl extends DisposableBase implements NativePytho
})
.then((environment) => {
this.outputChannel.info(`Resolved ${environment.executable}`);
this.outputChannel.trace(`Environment resolved:\n ${JSON.stringify(data, undefined, 4)}`);
discovered.fire(environment);
})
.catch((ex) => this.outputChannel.error(`Error in Resolving ${JSON.stringify(data)}`, ex));
Expand Down
35 changes: 22 additions & 13 deletions src/client/pythonEnvironments/nativeAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function toPythonEnvInfo(finder: NativePythonFinder, nativeEnv: NativeEnvInfo):
if (!validEnv(finder, nativeEnv)) {
return undefined;
}
const kind = finder.categoryToKind(nativeEnv.category);
const kind = finder.categoryToKind(nativeEnv.kind);
const arch = toArch(nativeEnv.arch);
const version: PythonVersion = parseVersion(nativeEnv.version ?? '');
const name = getName(nativeEnv, kind);
Expand Down Expand Up @@ -230,18 +230,27 @@ class NativePythonEnvironments implements IDiscoveryAPI, Disposable {
try {
if (validEnv(this.finder, native)) {
if (!native.version) {
this.resolveEnv(native.executable ?? native.prefix)
.then(() => {
const env = toPythonEnvInfo(this.finder, native);
if (env) {
this._envs.push(env);
this._onChanged.fire({
type: FileChangeType.Created,
new: env,
});
}
})
.ignoreErrors();
if (
this.finder.categoryToKind(native.kind) === PythonEnvKind.Conda &&
!native.executable
) {
// This is a conda env without python, no point trying to resolve this.
// TODO: we still need to add this to this._envs
traceError(`Unhandled Conda environment without python: ${native.prefix}`);
} else {
this.resolveEnv(native.executable ?? native.prefix)
.then(() => {
const env = toPythonEnvInfo(this.finder, native);
if (env) {
this._envs.push(env);
this._onChanged.fire({
type: FileChangeType.Created,
new: env,
});
}
})
.ignoreErrors();
}
} else {
const version = parseVersion(native.version);
if (version.micro < 0 || version.minor < 0 || version.major < 0) {
Expand Down

0 comments on commit 87f4382

Please sign in to comment.