Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: support search_paths option in QGIS finder job #535

Merged
merged 14 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions docs/jobs/qgis_installation_finder.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Sample job configuration in your scenario file:
with:
version_priority:
- "3.36"
search_paths:
- D:\\Applications\\QGIS\\
if_not_found: error
```

Expand Down Expand Up @@ -55,6 +57,25 @@ If any version of `version_priority` is available, then the most recent version

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

### search_paths

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.

For example if you define:

```yaml
- name: Find installed QGIS
uses: qgis-installation-finder
with:
version_priority:
- "3.36"
search_paths:
- D:/Install/QGIS 3.36
- D:/OtherInstall/QGIS 3.36
```

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).

### if_not_found

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

## How does it work

On Linux, QDT locates installed QGIS with `which` command.
On Windows QDT tries to locate installed versions in the following directories:
On Linux, QDT locates installed QGIS with `which` command and will search for available installation with the `search_paths` option.

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:

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

By default, the most recent version found is used.
Expand Down
8 changes: 8 additions & 0 deletions docs/schemas/scenario/jobs/qgis-installation-finder.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
"error"
],
"type": "string"
},
"search_paths": {
"default": "",
"description": "Define search paths for QGIS installation.",
"type": "array",
"items": {
"type": "string"
}
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions examples/scenarios/demo-scenario-http.qdt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ steps:
uses: qgis-installation-finder
with:
version_priority:
- "3.40"
- "3.34"
- "3.28"
- "3.38"
- "3.36"
- "3.32"
search_paths:
- "%PROGRAMFILES%/QGIS"
if_not_found: warn

- name: Download profiles from remote git repository
uses: qprofiles-downloader
with:
Expand Down
9 changes: 9 additions & 0 deletions examples/scenarios/demo-scenario.qdt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ steps:
uses: qgis-installation-finder
with:
version_priority:
- "3.40"
- "3.34"
- "3.28"
- "3.38"
- "3.36"
- "3.32"
search_paths:
- "%PROGRAMFILES%/QGIS"
if_not_found: warn

- name: Download profiles from remote git repository
uses: qprofiles-downloader
with:
Expand Down
4 changes: 4 additions & 0 deletions qgis_deployment_toolbelt/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# Standard library
import ast
import logging
import re
from dataclasses import dataclass
from os import PathLike, getenv
from os.path import expanduser, expandvars
Expand Down Expand Up @@ -44,6 +45,9 @@
# Operating systems
SUPPORTED_OPERATING_SYSTEMS_CODENAMES: tuple[str, ...] = ("darwin", "linux", "win32")

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

# #############################################################################
# ########## Functions #############
Expand Down
Loading