Returns a list of dicts with data formatted for the installation options page. Options are ordered to match the EXE (NSIS) installer for consistency: 1. Create shortcuts 2. Add to PATH (initialize_conda) 3. Register Python 4. Clear package cache 5. Pre-install script 6.
(info: dict)
| 267 | |
| 268 | |
| 269 | def create_install_options_list(info: dict) -> list[dict]: |
| 270 | """Returns a list of dicts with data formatted for the installation options page. |
| 271 | |
| 272 | Options are ordered to match the EXE (NSIS) installer for consistency: |
| 273 | 1. Create shortcuts |
| 274 | 2. Add to PATH (initialize_conda) |
| 275 | 3. Register Python |
| 276 | 4. Clear package cache |
| 277 | 5. Pre-install script |
| 278 | 6. Post-install script |
| 279 | """ |
| 280 | options = [] |
| 281 | |
| 282 | # 1. Enable shortcuts |
| 283 | if info.get("_enable_shortcuts", False) is True: |
| 284 | options.append( |
| 285 | { |
| 286 | "name": "enable_shortcuts", |
| 287 | "title": "Create shortcuts", |
| 288 | "description": "Create shortcuts (supported packages only).", |
| 289 | "default": True, |
| 290 | } |
| 291 | ) |
| 292 | |
| 293 | # 2. Initialize conda (Add to PATH) |
| 294 | initialize_conda = info.get("initialize_conda", "classic") |
| 295 | if initialize_conda: |
| 296 | if initialize_conda == "condabin": |
| 297 | description = ( |
| 298 | "Adds condabin, which only contains the 'conda' executables, to PATH. " |
| 299 | "Does not require special shortcuts but activation needs " |
| 300 | "to be performed manually." |
| 301 | ) |
| 302 | else: |
| 303 | description = ( |
| 304 | "NOT recommended. This can lead to conflicts with other applications. " |
| 305 | "Instead, use the Command Prompt and Powershell menus added to the Windows Start Menu." |
| 306 | ) |
| 307 | options.append( |
| 308 | { |
| 309 | "name": "initialize_conda", |
| 310 | "title": "Add installation to my PATH environment variable", |
| 311 | "description": description, |
| 312 | "default": info.get("initialize_by_default", False), |
| 313 | } |
| 314 | ) |
| 315 | |
| 316 | # 3. Register Python (if Python is bundled) |
| 317 | has_python = False |
| 318 | for item in info.get("_dists", []): |
| 319 | if item.startswith("python-"): |
| 320 | components = item.split("-") # python-x.y.z-<build number>.suffix |
| 321 | python_version = ".".join(components[1].split(".")[:-1]) # create the string "x.y" |
| 322 | has_python = True |
| 323 | break |
| 324 | |
| 325 | if has_python and info.get("register_python", True): |
| 326 | options.append( |
no test coverage detected