(
name: string,
interpreter?: PythonEnvironment,
rootKernelFilePath?: Uri
)
| 69 | * Create a default kernelspec with the given display name. |
| 70 | */ |
| 71 | export function createInterpreterKernelSpecWithName( |
| 72 | name: string, |
| 73 | interpreter?: PythonEnvironment, |
| 74 | rootKernelFilePath?: Uri |
| 75 | ): IJupyterKernelSpec { |
| 76 | const interpreterMetadata = interpreter |
| 77 | ? { |
| 78 | path: getFilePath(interpreter.uri) |
| 79 | } |
| 80 | : {}; |
| 81 | // This creates a kernel spec for an interpreter. When launched, 'python' argument will map to using the interpreter |
| 82 | // associated with the current resource for launching. |
| 83 | const defaultSpec: KernelSpec.ISpecModel = { |
| 84 | name, |
| 85 | language: 'python', |
| 86 | display_name: (interpreter ? getCachedEnvironment(interpreter)?.environment?.name : '') || 'Python 3', |
| 87 | metadata: { |
| 88 | interpreter: interpreterMetadata |
| 89 | }, |
| 90 | argv: ['python', '-m', 'ipykernel_launcher', '-f', connectionFilePlaceholder], |
| 91 | env: {}, |
| 92 | resources: {} |
| 93 | }; |
| 94 | |
| 95 | // Generate spec file path if we know where kernel files will go |
| 96 | const specFile = |
| 97 | rootKernelFilePath && defaultSpec.name |
| 98 | ? uriPath.joinPath(rootKernelFilePath, defaultSpec.name, 'kernel.json') |
| 99 | : undefined; |
| 100 | |
| 101 | return new JupyterKernelSpec( |
| 102 | defaultSpec, |
| 103 | specFile ? getFilePath(specFile) : undefined, |
| 104 | getFilePath(interpreter?.uri), |
| 105 | 'registeredByNewVersionOfExt' |
| 106 | ); |
| 107 | } |
| 108 | |
| 109 | export function cleanEnvironment<T>(spec: T): T { |
| 110 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
no test coverage detected