22// Licensed under the MIT License.
33
44import type { Pep440Version } from '@renovatebot/pep440' ;
5- < < < << << HEAD :src / internal . api . ts
6- import * as path from 'path' ;
7- import {
8- CancellationError ,
9- Disposable ,
10- Event ,
11- FileType ,
12- LogOutputChannel ,
13- MarkdownString ,
14- RelativePattern ,
15- Uri ,
16- } from 'vscode' ;
17- import {
18- = === ===
195import { CancellationError , Disposable , LogOutputChannel , MarkdownString , RelativePattern } from 'vscode' ;
206import { PackageVersionLookupNotSupportedError } from '../../publicErrors' ;
217import { ISSUES_URL } from '../../common/constants' ;
@@ -26,7 +12,6 @@ import { EventNames } from '../../common/telemetry/constants';
2612import { classifyError , isTimeoutErrorType } from '../../common/telemetry/errorClassifier' ;
2713import { sendTelemetryEvent } from '../../common/telemetry/sender' ;
2814import type {
29- > >>> >>> origin / m a i n : s r c / managers/ common / registeredManagers . ts
3015 CreateEnvironmentOptions ,
3116 CreateEnvironmentScope ,
3217 DidChangeEnvironmentEventArgs ,
@@ -47,19 +32,7 @@ import type {
4732 RemoveEnvironmentOptions ,
4833 ResolveEnvironmentContext ,
4934 SetEnvironmentScope ,
50- < < < << << HEAD :src / internal . api . ts
51- } from './api' ;
52- import { ISSUES_URL } from './common/constants' ;
53- import { CreateEnvironmentNotSupported , RemoveEnvironmentNotSupported } from './common/errors/NotSupportedError' ;
54- import { traceWarn } from './common/logging' ;
55- import { StopWatch } from './common/stopWatch' ;
56- import { EventNames } from './common/telemetry/constants' ;
57- import { classifyError , isTimeoutErrorType } from './common/telemetry/errorClassifier' ;
58- import { sendTelemetryEvent } from './common/telemetry/sender' ;
59- import { stat } from './common/workspace.fs.apis' ;
60- = === ===
6135} from '../../types' ;
62- > >>> >>> origin / main :src / managers / common / registeredManagers . ts
6336
6437/*
6538 * Runtime wrappers around registered {@link EnvironmentManager} and {@link PackageManager}
@@ -367,164 +340,3 @@ export class InternalPackageManager implements PackageManager {
367340 : `${ packageName } ==${ version } ` ;
368341 }
369342}
370- < < < << << HEAD :src / internal . api . ts
371-
372- export interface PythonProjectManager extends Disposable {
373- initialize ( ) : void ;
374- create (
375- name : string ,
376- uri : Uri ,
377- options ?: { description ?: string ; tooltip ?: string | MarkdownString ; iconPath ?: IconPath } ,
378- ) : PythonProject ;
379- add ( pyWorkspace : PythonProject | PythonProject [ ] , options ?: { persistSettings ?: boolean } ) : Promise < void > ;
380- remove ( pyWorkspace : PythonProject | PythonProject [ ] ) : void ;
381- getProjects ( uris ?: Uri [ ] ) : ReadonlyArray < PythonProject > ;
382- get ( uri : Uri ) : PythonProject | undefined ;
383- onDidChangeProjects : Event < PythonProject [ ] | undefined > ;
384- }
385-
386- export type InlineScriptProjectRegistrationKind = 'created ' | 'adopted' ;
387-
388- export interface InlineScriptProjectRegistrationMarker {
389- readonly kind : InlineScriptProjectRegistrationKind ;
390- }
391-
392- export interface PythonProjectSettings {
393- path : string ;
394- envManager : string ;
395- packageManager : string ;
396- workspace ?: string ;
397- _inlineScriptRegistration ?: InlineScriptProjectRegistrationMarker ;
398- }
399-
400- export class PythonEnvironmentImpl implements PythonEnvironment {
401- public readonly name : string ;
402- public readonly displayName : string ;
403- public readonly shortDisplayName ?: string ;
404- public readonly displayPath : string ;
405- public readonly version : string ;
406- public readonly environmentPath : Uri ;
407- public readonly description ?: string ;
408- public readonly tooltip ?: string | MarkdownString ;
409- public readonly iconPath ?: IconPath ;
410- public readonly execInfo : PythonEnvironmentExecutionInfo ;
411- public readonly sysPrefix : string ;
412- public readonly group ?: string | EnvironmentGroupInfo ;
413- public readonly error ?: string ;
414-
415- constructor (
416- public readonly envId : PythonEnvironmentId ,
417- info : PythonEnvironmentInfo ,
418- ) {
419- this . name = info . name ;
420- this . displayName = info . displayName ? ? this. name ;
421- this. shortDisplayName = info . shortDisplayName ;
422- this. displayPath = info . displayPath ;
423- this. version = info . version ;
424- this. environmentPath = info . environmentPath ;
425- this. description = info . description ;
426- this. tooltip = info . tooltip ;
427- this. iconPath = info . iconPath ;
428- this. execInfo = info . execInfo ;
429- this. sysPrefix = info . sysPrefix ;
430- this. group = info . group ;
431- this. error = info . error ;
432- }
433- }
434-
435- export class PythonPackageImpl implements Package {
436- public readonly name : string ;
437- public readonly displayName : string ;
438- public readonly version ?: string ;
439- public readonly description ?: string ;
440- public readonly tooltip ?: string | MarkdownString ;
441- public readonly iconPath ?: IconPath ;
442- public readonly uris ?: readonly Uri [ ] ;
443-
444- public readonly isTransitive ?: boolean ;
445-
446- constructor (
447- public readonly pkgId : PackageId ,
448- info : PackageInfo ,
449- ) {
450- this . name = info . name ;
451- this . displayName = info . displayName ?? this . name ;
452- this . version = info . version ;
453- this . description = info . description ;
454- this . tooltip = info . tooltip ;
455- this . iconPath = info . iconPath ;
456- this . uris = info . uris ;
457- this . isTransitive = info . isTransitive ;
458- }
459- }
460-
461- export class PythonProjectsImpl implements PythonProject {
462- private static readonly dependencyFileNames = [
463- 'requirements.txt' ,
464- 'pyproject.toml' ,
465- 'requirements.in' ,
466- 'environment.yml' ,
467- ] as const ;
468-
469- name : string ;
470- uri : Uri ;
471- description ?: string;
472- tooltip ?: string | MarkdownString ;
473- iconPath ?: IconPath ;
474-
475- constructor (
476- name : string ,
477- uri : Uri ,
478- options ?: { description ?: string ; tooltip ?: string | MarkdownString ; iconPath ?: IconPath } ,
479- ) {
480- this . name = name ;
481- this . uri = uri ;
482- this . description = options ?. description ?? uri . fsPath ;
483- this . tooltip = options ?. tooltip ?? uri . fsPath ;
484- this . iconPath = options ?. iconPath ;
485- }
486-
487- /**
488- * Finds the preferred dependency file at the project root.
489- * @returns The dependency file URI, or `undefined` when no supported dependency file exists.
490- */
491- async discoverDependencyFiles ( ) : Promise < Uri | undefined > {
492- let projectType : FileType ;
493- try {
494- projectType = ( await stat ( this . uri ) ) . type ;
495- } catch {
496- return undefined ;
497- }
498-
499- // A project URI may point directly to a dependency file instead of its parent directory.
500- if ( projectType !== FileType . Directory ) {
501- const fileName = path . posix . basename ( this . uri . path ) ;
502- return projectType === FileType . File &&
503- PythonProjectsImpl . dependencyFileNames . some ( ( candidate ) => candidate === fileName )
504- ? this . uri
505- : undefined ;
506- }
507-
508- // Search directory candidates in dependency-file priority order.
509- for ( const fileName of PythonProjectsImpl . dependencyFileNames ) {
510- const candidate = this . uri . with ( { path : path . posix . join ( this . uri . path , fileName ) } ) ;
511- try {
512- const candidateType = ( await stat ( candidate ) ) . type ;
513- if ( candidateType === FileType . File ) {
514- return candidate ;
515- }
516- } catch {
517- // Try the next supported dependency file.
518- }
519- }
520-
521- return undefined ;
522- }
523- }
524-
525- export interface ProjectCreators extends Disposable {
526- registerPythonProjectCreator ( creator : PythonProjectCreator ) : Disposable ;
527- getProjectCreators ( ) : PythonProjectCreator [ ] ;
528- }
529- === === =
530- >>> >>> > origin / m a i n : s r c / managers/ common / registeredManagers . ts
0 commit comments