|
11 | 11 | folder `.local` in the user's home directory is also searched to allow |
12 | 12 | symbolic linking to a custom location. |
13 | 13 |
|
14 | | -In a last step, we also run the shell command `where comsol` (on Windows) |
| 14 | +Additionally, we also run the shell command `where comsol` (on Windows) |
15 | 15 | or `which comsol` (on Linux and macOS) to find a Comsol installation |
16 | 16 | that isn't in a default location, but for which the Comsol executable |
17 | 17 | was added to the executable search path. |
18 | 18 |
|
19 | 19 | Note that duplicate installations will be ignored. That is, a Comsol |
20 | 20 | installation found in a later step that reports the same version as one |
21 | 21 | found in an earlier step will be ignored, regardless of install location. |
| 22 | +The one found on the search path, if any, will be prioritized. |
22 | 23 | """ |
23 | 24 |
|
24 | 25 | from __future__ import annotations |
@@ -232,7 +233,7 @@ def search_disk(architecture: str) -> list[Path]: |
232 | 233 | return executables |
233 | 234 |
|
234 | 235 |
|
235 | | -def lookup_comsol() -> Path | None: |
| 236 | +def search_path() -> Path | None: |
236 | 237 | """Returns Comsol executable if found on the system's search path.""" |
237 | 238 |
|
238 | 239 | log.debug('Looking for Comsol executable on system search path.') |
@@ -289,10 +290,14 @@ def find_backends() -> list[Backend]: |
289 | 290 | raise NotImplementedError(error) |
290 | 291 |
|
291 | 292 | # Look up `comsol` command as if run in terminal. |
292 | | - comsol = lookup_comsol() |
| 293 | + comsol = search_path() |
293 | 294 | if comsol: |
294 | 295 | if comsol not in executables: |
295 | | - executables.append(comsol) |
| 296 | + executables.insert(0, comsol) |
| 297 | + # We put that Comsol executable first so that users have a way of |
| 298 | + # prioritizing one Comsol installation over another. This makes |
| 299 | + # sense for multiple installations of the same Comsol version, each |
| 300 | + # with a single-user license for a different user. |
296 | 301 | else: |
297 | 302 | log.debug('Ignoring executable as it was previously found.') |
298 | 303 |
|
|
0 commit comments