Skip to content

Commit

Permalink
Remove code
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Oct 19, 2021
1 parent f55dfb7 commit 62659b0
Show file tree
Hide file tree
Showing 68 changed files with 55 additions and 9,258 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,6 @@ jobs:
& $condaPythonPath ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} condaPath
& $condaExecPath init --all
# 2. For `interpreterLocatorService.testvirtualenvs.ts`
& $condaExecPath create -n "test_env1" -y python
& $condaExecPath create -p "./test_env2" -y python
& $condaExecPath create -p "~/test_env3" -y python
- name: Set CI_PYTHON_PATH and CI_DISABLE_AUTO_SELECTION
run: |
echo "CI_PYTHON_PATH=python" >> $GITHUB_ENV
Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,6 @@ jobs:
& $condaPythonPath ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} condaPath
& $condaExecPath init --all
# 2. For `interpreterLocatorService.testvirtualenvs.ts`
& $condaExecPath create -n "test_env1" -y python
& $condaExecPath create -p "./test_env2" -y python
& $condaExecPath create -p "~/test_env3" -y python
- name: Set CI_PYTHON_PATH and CI_DISABLE_AUTO_SELECTION
run: |
echo "CI_PYTHON_PATH=python" >> $GITHUB_ENV
Expand Down Expand Up @@ -458,12 +452,6 @@ jobs:
& $condaPythonPath ./build/ci/addEnvPath.py ${{ env.PYTHON_VIRTUAL_ENVS_LOCATION }} condaPath
& $condaExecPath init --all
# 2. For `interpreterLocatorService.testvirtualenvs.ts`
& $condaExecPath create -n "test_env1" -y python
& $condaExecPath create -p "./test_env2" -y python
& $condaExecPath create -p "~/test_env3" -y python
- name: Run TypeScript unit tests
run: npm run test:unittests:cover

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,44 @@ import { inject, injectable } from 'inversify';
import * as path from 'path';
import { Uri } from 'vscode';
import { IServiceContainer } from '../../../ioc/types';
import { getVenvExecutableFinder } from '../../../pythonEnvironments/discovery/subenv';
import { IFileSystem } from '../../platform/types';
import { IConfigurationService } from '../../types';
import { ITerminalActivationCommandProvider, TerminalShellType } from '../types';

type ExecutableFinderFunc = (python: string) => Promise<string | undefined>;

/**
* Build an "executable finder" function that identifies venv environments.
*
* @param basename - the venv name or names to look for
* @param pathDirname - typically `path.dirname`
* @param pathJoin - typically `path.join`
* @param fileExists - typically `fs.exists`
*/

function getVenvExecutableFinder(
basename: string | string[],
// <path>
pathDirname: (filename: string) => string,
pathJoin: (...parts: string[]) => string,
// </path>
fileExists: (n: string) => Promise<boolean>,
): ExecutableFinderFunc {
const basenames = typeof basename === 'string' ? [basename] : basename;
return async (python: string) => {
// Generated scripts are found in the same directory as the interpreter.
const binDir = pathDirname(python);
for (const name of basenames) {
const filename = pathJoin(binDir, name);
if (await fileExists(filename)) {
return filename;
}
}
// No matches so return undefined.
return undefined;
};
}

@injectable()
abstract class BaseActivationCommandProvider implements ITerminalActivationCommandProvider {
constructor(@inject(IServiceContainer) protected readonly serviceContainer: IServiceContainer) {}
Expand Down
76 changes: 2 additions & 74 deletions src/client/interpreter/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,15 @@
import { SemVer } from 'semver';
import { CodeLensProvider, ConfigurationTarget, Disposable, Event, TextDocument, Uri } from 'vscode';
import { IExtensionSingleActivationService } from '../activation/types';
import { FileChangeType } from '../common/platform/fileSystemWatcher';
import { Resource } from '../common/types';
import { PythonEnvSource } from '../pythonEnvironments/base/info';
import { PythonLocatorQuery } from '../pythonEnvironments/base/locator';
import { CondaEnvironmentInfo, CondaInfo } from '../pythonEnvironments/common/environmentManagers/conda';
import { CondaEnvironmentInfo } from '../pythonEnvironments/common/environmentManagers/conda';
import { EnvironmentType, PythonEnvironment } from '../pythonEnvironments/info';

export const INTERPRETER_LOCATOR_SERVICE = 'IInterpreterLocatorService';
export const WINDOWS_REGISTRY_SERVICE = 'WindowsRegistryService';
export const CONDA_ENV_FILE_SERVICE = 'CondaEnvFileService';
export const CONDA_ENV_SERVICE = 'CondaEnvService';
export const CURRENT_PATH_SERVICE = 'CurrentPathService';
export const KNOWN_PATH_SERVICE = 'KnownPathsService';
export const GLOBAL_VIRTUAL_ENV_SERVICE = 'VirtualEnvService';
export const WORKSPACE_VIRTUAL_ENV_SERVICE = 'WorkspaceVirtualEnvService';
export const PIPENV_SERVICE = 'PipEnvService';
export const IInterpreterVersionService = Symbol('IInterpreterVersionService');
export interface IInterpreterVersionService {
getVersion(pythonPath: string, defaultValue: string): Promise<string>;
getPipVersion(pythonPath: string): Promise<string>;
}

export const IKnownSearchPathsForInterpreters = Symbol('IKnownSearchPathsForInterpreters');
export interface IKnownSearchPathsForInterpreters {
getSearchPaths(): string[];
}
export const IVirtualEnvironmentsSearchPathProvider = Symbol('IVirtualEnvironmentsSearchPathProvider');
export interface IVirtualEnvironmentsSearchPathProvider {
getSearchPaths(resource?: Uri): Promise<string[]>;
}

export type PythonEnvironmentsChangedEvent = {
Expand Down Expand Up @@ -74,15 +54,6 @@ export interface IComponentAdapter {
isWindowsStoreInterpreter(pythonPath: string): Promise<boolean>;
}

export const IInterpreterLocatorService = Symbol('IInterpreterLocatorService');

export interface IInterpreterLocatorService extends Disposable {
readonly onLocating: Event<Promise<PythonEnvironment[]>>;
readonly hasInterpreters: Promise<boolean>;
didTriggerInterpreterSuggestions?: boolean;
getInterpreters(resource?: Uri, options?: GetInterpreterOptions): Promise<PythonEnvironment[]>;
}

export const ICondaService = Symbol('ICondaService');
/**
* Interface carries the properties which are not available via the discovery component interface.
Expand All @@ -94,20 +65,6 @@ export interface ICondaService {
getCondaFileFromInterpreter(interpreterPath?: string, envName?: string): Promise<string | undefined>;
}

export const ICondaLocatorService = Symbol('ICondaLocatorService');
/**
* @deprecated Use the new discovery component when in experiment, use this otherwise.
*/
export interface ICondaLocatorService {
readonly condaEnvironmentsFile: string | undefined;
getCondaFile(): Promise<string>;
getCondaInfo(): Promise<CondaInfo | undefined>;
getCondaEnvironments(ignoreCache: boolean): Promise<CondaEnvironmentInfo[] | undefined>;
getInterpreterPath(condaEnvironmentPath: string): string;
isCondaEnvironment(interpreterPath: string): Promise<boolean>;
getCondaEnvironment(interpreterPath: string): Promise<CondaEnvironmentInfo | undefined>;
}

export const IInterpreterService = Symbol('IInterpreterService');
export interface IInterpreterService {
readonly onRefreshStart: Event<void>;
Expand All @@ -119,7 +76,7 @@ export interface IInterpreterService {
onDidChangeInterpreterInformation: Event<PythonEnvironment>;
hasInterpreters(filter?: (e: PythonEnvironment) => Promise<boolean>): Promise<boolean>;
getInterpreters(resource?: Uri): PythonEnvironment[];
getAllInterpreters(resource?: Uri, options?: GetInterpreterOptions): Promise<PythonEnvironment[]>;
getAllInterpreters(resource?: Uri): Promise<PythonEnvironment[]>;
getActiveInterpreter(resource?: Uri): Promise<PythonEnvironment | undefined>;
getInterpreterDetails(pythonPath: string, resoure?: Uri): Promise<undefined | PythonEnvironment>;
refresh(resource: Resource): Promise<void>;
Expand All @@ -146,33 +103,6 @@ export interface IInterpreterHelper {
getBestInterpreter(interpreters?: PythonEnvironment[]): PythonEnvironment | undefined;
}

export const IPipEnvService = Symbol('IPipEnvService');
export interface IPipEnvService extends IInterpreterLocatorService {
executable: string;
isRelatedPipEnvironment(dir: string, pythonPath: string): Promise<boolean>;
}

export const IInterpreterLocatorHelper = Symbol('IInterpreterLocatorHelper');
export interface IInterpreterLocatorHelper {
mergeInterpreters(interpreters: PythonEnvironment[]): Promise<PythonEnvironment[]>;
}

export const IInterpreterWatcher = Symbol('IInterpreterWatcher');
export interface IInterpreterWatcher {
onDidCreate: Event<Resource>;
}

export const IInterpreterWatcherBuilder = Symbol('IInterpreterWatcherBuilder');
export interface IInterpreterWatcherBuilder {
getWorkspaceVirtualEnvInterpreterWatcher(resource: Resource): Promise<IInterpreterWatcher>;
}

export const IInterpreterLocatorProgressService = Symbol('IInterpreterLocatorProgressService');
export interface IInterpreterLocatorProgressService extends IExtensionSingleActivationService {
readonly onRefreshing: Event<void>;
readonly onRefreshed: Event<void>;
}

export const IInterpreterStatusbarVisibilityFilter = Symbol('IInterpreterStatusbarVisibilityFilter');
/**
* Implement this interface to control the visibility of the interpreter statusbar.
Expand All @@ -186,5 +116,3 @@ export type WorkspacePythonPath = {
folderUri: Uri;
configTarget: ConfigurationTarget.Workspace | ConfigurationTarget.WorkspaceFolder;
};

export type GetInterpreterOptions = { ignoreCache?: boolean; onSuggestion?: boolean };
20 changes: 0 additions & 20 deletions src/client/interpreter/interpreterVersion.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { inject, injectable } from 'inversify';
import '../common/extensions';
import * as internalPython from '../common/process/internal/python';
import { IProcessServiceFactory } from '../common/process/types';
import { getPythonVersion } from '../pythonEnvironments/info/pythonVersion';
import { IInterpreterVersionService } from './contracts';

const PIP_VERSION_REGEX = '\\d+\\.\\d+(\\.\\d+)?';

@injectable()
export class InterpreterVersionService implements IInterpreterVersionService {
constructor(@inject(IProcessServiceFactory) private readonly processServiceFactory: IProcessServiceFactory) {}
Expand All @@ -17,21 +14,4 @@ export class InterpreterVersionService implements IInterpreterVersionService {
processService.exec(cmd, args, { mergeStdOutErr: true }),
);
}

public async getPipVersion(pythonPath: string): Promise<string> {
const [args, parse] = internalPython.getModuleVersion('pip');
const processService = await this.processServiceFactory.create();
const output = await processService.exec(pythonPath, args, { mergeStdOutErr: true });
const version = parse(output.stdout);
if (version.length > 0) {
// Here's a sample output:
// pip 9.0.1 from /Users/donjayamanne/anaconda3/lib/python3.6/site-packages (python 3.6).
const re = new RegExp(PIP_VERSION_REGEX, 'g');
const matches = re.exec(version);
if (matches && matches.length > 0) {
return matches[0].trim();
}
}
throw new Error(`Unable to determine pip version from output '${output.stdout}'`);
}
}
147 changes: 0 additions & 147 deletions src/client/interpreter/virtualEnvs/index.ts

This file was deleted.

Loading

0 comments on commit 62659b0

Please sign in to comment.