(dispatcher: TaskEventDispatcher)
| 181 | * @returns |
| 182 | */ |
| 183 | export async function installPythonTask(dispatcher: TaskEventDispatcher): Promise<boolean> { |
| 184 | let success = false; |
| 185 | let lastError = null; |
| 186 | for (let i = 0; i < 3; i++) { |
| 187 | try { |
| 188 | if (await checkIfInstalled("python")) { |
| 189 | dispatcher({ |
| 190 | message: `Already Find Python=3.10.8` |
| 191 | }); |
| 192 | return true; |
| 193 | } |
| 194 | dispatcher({ |
| 195 | message: `Start installing Python=3.10.8` |
| 196 | }); |
| 197 | await runCommand(`conda create -c anaconda -n ${CONDA_ENV_NAME} python=3.10.8 -y`, dispatcher); |
| 198 | |
| 199 | dispatcher({ |
| 200 | message: `Install Python=3.10.8 finished` |
| 201 | }); |
| 202 | conda.updateCondaInfo(); |
| 203 | success = true; |
| 204 | break; |
| 205 | } catch (e: any) { |
| 206 | lastError = e; |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | if (!success) { |
| 211 | throw new Error(`Install python error: ${lastError.message}`); |
| 212 | } |
| 213 | return true; |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * install any conda package |
no test coverage detected