Skip to content

Commit 0e4e6d1

Browse files
authored
Feature: support search_paths option in QGIS finder job (#535)
Close #523 Search of QGIS installed binary is now done recursively from a list of search paths.
2 parents 4fad74e + b2477a5 commit 0e4e6d1

File tree

8 files changed

+242
-84
lines changed

8 files changed

+242
-84
lines changed

docs/jobs/qgis_installation_finder.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Sample job configuration in your scenario file:
2525
with:
2626
version_priority:
2727
- "3.36"
28+
search_paths:
29+
- D:\\Applications\\QGIS\\
2830
if_not_found: error
2931
```
3032
@@ -55,6 +57,25 @@ If any version of `version_priority` is available, then the most recent version
5557

5658
The environment variable `QDT_PREFERRED_QGIS_VERSION` is used as top priority if defined.
5759

60+
### search_paths
61+
62+
This option can be used to define search paths for QGIS installation. The order of the paths is used to define which path will be used in case of multiple installation for same QGIS version.
63+
64+
For example if you define:
65+
66+
```yaml
67+
- name: Find installed QGIS
68+
uses: qgis-installation-finder
69+
with:
70+
version_priority:
71+
- "3.36"
72+
search_paths:
73+
- D:/Install/QGIS 3.36
74+
- D:/OtherInstall/QGIS 3.36
75+
```
76+
77+
QDT will find two installation for version 3.36 but the first available in `search_paths` will be used (`D:/Install/QGIS 3.36` in our case).
78+
5879
### if_not_found
5980

6081
This option determines the action to be taken if QGIS is not found during the search process.
@@ -68,10 +89,11 @@ Possible_values:
6889

6990
## How does it work
7091

71-
On Linux, QDT locates installed QGIS with `which` command.
72-
On Windows QDT tries to locate installed versions in the following directories:
92+
On Linux, QDT locates installed QGIS with `which` command and will search for available installation with the `search_paths` option.
93+
94+
On Windows QDT tries to locate installed versions in the directories in `search_paths` option. If the option is not defined, QDT will search in these directories:
7395

74-
- `%PROGRAMFILES%\\QGIS x.y.z\\bin\`
96+
- `%PROGRAMFILES%\\QGIS x.y.z\` (by using a regexp to get available QGIS versions)
7597
- `%QDT_OSGEO4W_INSTALL_DIR%` (default value : `C:\\OSGeo4W`)
7698

7799
By default, the most recent version found is used.

docs/schemas/scenario/jobs/qgis-installation-finder.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
"error"
2424
],
2525
"type": "string"
26+
},
27+
"search_paths": {
28+
"default": "",
29+
"description": "Define search paths for QGIS installation.",
30+
"type": "array",
31+
"items": {
32+
"type": "string"
33+
}
2634
}
2735
}
2836
}

examples/scenarios/demo-scenario-http.qdt.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@ steps:
1616
uses: qgis-installation-finder
1717
with:
1818
version_priority:
19+
- "3.40"
20+
- "3.34"
21+
- "3.28"
22+
- "3.38"
1923
- "3.36"
24+
- "3.32"
25+
search_paths:
26+
- "%PROGRAMFILES%/QGIS"
27+
if_not_found: warn
28+
2029
- name: Download profiles from remote git repository
2130
uses: qprofiles-downloader
2231
with:

examples/scenarios/demo-scenario.qdt.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ steps:
2121
uses: qgis-installation-finder
2222
with:
2323
version_priority:
24+
- "3.40"
25+
- "3.34"
26+
- "3.28"
27+
- "3.38"
2428
- "3.36"
29+
- "3.32"
30+
search_paths:
31+
- "%PROGRAMFILES%/QGIS"
32+
if_not_found: warn
33+
2534
- name: Download profiles from remote git repository
2635
uses: qprofiles-downloader
2736
with:

qgis_deployment_toolbelt/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# Standard library
1818
import ast
1919
import logging
20+
import re
2021
from dataclasses import dataclass
2122
from os import PathLike, getenv
2223
from os.path import expanduser, expandvars
@@ -44,6 +45,9 @@
4445
# Operating systems
4546
SUPPORTED_OPERATING_SYSTEMS_CODENAMES: tuple[str, ...] = ("darwin", "linux", "win32")
4647

48+
# regex
49+
RE_QGIS_FINDER_DIR = re.compile(r"QGIS (\d+)\.(\d+)\.(\d+)", re.IGNORECASE)
50+
RE_QGIS_FINDER_VERSION = re.compile(r"QGIS (\d+\.\d+\.\d+)-(\w+).*")
4751

4852
# #############################################################################
4953
# ########## Functions #############

0 commit comments

Comments
 (0)