(env: Environment)
| 89 | return env ? getEnvironmentTypeImpl(env) : EnvironmentType.Unknown; |
| 90 | } |
| 91 | function getEnvironmentTypeImpl(env: Environment): EnvironmentType { |
| 92 | if ((env.environment?.type as KnownEnvironmentTypes) === 'Conda') { |
| 93 | return EnvironmentType.Conda; |
| 94 | } |
| 95 | |
| 96 | // Map the Python env tool to a Jupyter environment type. |
| 97 | const orderOrEnvs: [pythonEnvTool: KnownEnvironmentTools, JupyterEnv: EnvironmentType][] = [ |
| 98 | ['Conda', EnvironmentType.Conda], |
| 99 | ['Pyenv', EnvironmentType.Pyenv], |
| 100 | ['Pipenv', EnvironmentType.Pipenv], |
| 101 | ['Poetry', EnvironmentType.Poetry], |
| 102 | ['VirtualEnvWrapper', EnvironmentType.VirtualEnvWrapper], |
| 103 | ['VirtualEnv', EnvironmentType.VirtualEnv], |
| 104 | ['Venv', EnvironmentType.Venv] |
| 105 | ]; |
| 106 | for (const [pythonEnvTool, JupyterEnv] of orderOrEnvs) { |
| 107 | if (env.tools.includes(pythonEnvTool)) { |
| 108 | return JupyterEnv; |
| 109 | } |
| 110 | } |
| 111 | if (env.environment?.type === 'VirtualEnvironment') { |
| 112 | return EnvironmentType.VirtualEnv; |
| 113 | } |
| 114 | |
| 115 | for (const type of environmentTypes) { |
| 116 | if (env.tools.some((tool) => tool.toLowerCase() === type.toLowerCase())) { |
| 117 | return type; |
| 118 | } |
| 119 | } |
| 120 | return EnvironmentType.Unknown; |
| 121 | } |
| 122 | |
| 123 | export async function getInterpreterInfo(interpreter?: { id: string }) { |
| 124 | if (!interpreter?.id) { |
no outgoing calls
no test coverage detected