forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add PyEnvInfo and the other base info types for the Python environments component. #13708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ericsnowcurrently
merged 6 commits into
microsoft:master
from
ericsnowcurrently:pyenvs-component-base-info
Sep 1, 2020
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ecaa16f
Add "base" types for py envs.
ericsnowcurrently 2a0d849
Move the base info types to their own directory.
ericsnowcurrently d4a93fe
add release level
ericsnowcurrently 112bcca
Fix the base version type imports.
ericsnowcurrently 0a07fb8
Add ctime and mtime properties to PythonExecutableInfo.
ericsnowcurrently 2f4ecb9
Add PythonEnvInfo.searchLocation.
ericsnowcurrently File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { Uri } from 'vscode'; | ||
import { Architecture } from '../../../common/utils/platform'; | ||
import { BasicVersionInfo, VersionInfo } from '../../../common/utils/version'; | ||
|
||
/** | ||
* IDs for the various supported Python environments. | ||
*/ | ||
export enum PythonEnvKind { | ||
Unknown = 'unknown', | ||
// "global" | ||
System = 'global-system', | ||
MacDefault = 'global-mac-default', | ||
WindowsStore = 'global-windows-store', | ||
Pyenv = 'global-pyenv', | ||
CondaBase = 'global-conda-base', | ||
Custom = 'global-custom', | ||
OtherGlobal = 'global-other', | ||
// "virtual" | ||
Venv = 'virt-venv', | ||
VirtualEnv = 'virt-virtualenv', | ||
Pipenv = 'virt-pipenv', | ||
Conda = 'virt-conda', | ||
OtherVirtual = 'virt-other' | ||
} | ||
|
||
/** | ||
* Information about a Python binary/executable. | ||
*/ | ||
export type PythonExecutableInfo = { | ||
filename: string; | ||
sysPrefix: string; | ||
ctime: number; | ||
mtime: number; | ||
}; | ||
|
||
/** | ||
* A (system-global) unique ID for a single Python environment. | ||
*/ | ||
export type PythonEnvID = string; | ||
karrtikr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* The most fundamental information about a Python environment. | ||
* | ||
* You should expect these objects to be complete (no empty props). | ||
* Note that either `name` or `location` must be non-empty, though | ||
* the other *can* be empty. | ||
* | ||
* @prop id - the env's unique ID | ||
* @prop kind - the env's kind | ||
* @prop executable - info about the env's Python binary | ||
* @prop name - the env's distro-specific name, if any | ||
* @prop location - the env's location (on disk), if relevant | ||
*/ | ||
export type PythonEnvBaseInfo = { | ||
id: PythonEnvID; | ||
kind: PythonEnvKind; | ||
executable: PythonExecutableInfo; | ||
// One of (name, location) must be non-empty. | ||
name: string; | ||
location: string; | ||
// Other possible fields: | ||
// * managed: boolean (if the env is "managed") | ||
// * parent: PythonEnvBaseInfo (the env from which this one was created) | ||
// * binDir: string (where env-installed executables are found) | ||
}; | ||
|
||
/** | ||
* The possible Python release levels. | ||
*/ | ||
export enum PythonReleaseLevel { | ||
Alpha = 'alpha', | ||
Beta = 'beta', | ||
Candidate = 'candidate', | ||
Final = 'final' | ||
} | ||
|
||
/** | ||
* Release information for a Python version. | ||
*/ | ||
export type PythonVersionRelease = { | ||
level: PythonReleaseLevel; | ||
serial: number; | ||
}; | ||
|
||
/** | ||
* Version information for a Python build/installation. | ||
* | ||
* @prop sysVersion - the raw text from `sys.version` | ||
*/ | ||
export type PythonVersion = BasicVersionInfo & { | ||
release: PythonVersionRelease; | ||
sysVersion?: string; | ||
}; | ||
|
||
/** | ||
* Information for a Python build/installation. | ||
*/ | ||
export type PythonBuildInfo = { | ||
version: PythonVersion; // incl. raw, AKA sys.version | ||
arch: Architecture; | ||
}; | ||
|
||
/** | ||
* Meta information about a Python distribution. | ||
* | ||
* @prop org - the name of the distro's creator/publisher | ||
* @prop defaultDisplayName - the text to use when showing the distro to users | ||
*/ | ||
export type PythonDistroMetaInfo = { | ||
org: string; | ||
defaultDisplayName?: string; | ||
}; | ||
|
||
/** | ||
* Information about an installed Python distribution. | ||
* | ||
* @prop version - the installed *distro* version (not the Python version) | ||
* @prop binDir - where to look for the distro's executables (i.e. tools) | ||
*/ | ||
export type PythonDistroInfo = PythonDistroMetaInfo & { | ||
version?: VersionInfo; | ||
binDir?: string; | ||
}; | ||
|
||
type _PythonEnvInfo = PythonEnvBaseInfo & PythonBuildInfo; | ||
|
||
/** | ||
* All the available information about a Python environment. | ||
* | ||
* Note that not all the information will necessarily be filled in. | ||
* Locators are only required to fill in the "base" info, though | ||
* they will usually be able to provide the version as well. | ||
* | ||
* @prop distro - the installed Python distro that this env is using or belongs to | ||
* @prop defaultDisplayName - the text to use when showing the env to users | ||
* @prop searchLocation - the root under which a locator found this env, if any | ||
*/ | ||
export type PythonEnvInfo = _PythonEnvInfo & { | ||
karrtikr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
distro: PythonDistroInfo; | ||
karrtikr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
defaultDisplayName?: string; | ||
searchLocation?: Uri; | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this be replacing
EnvironmentType
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes (eventually)