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

Add macOS support #6

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
44 changes: 37 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install Hatch
run: pip install --upgrade hatch
uses: pypa/hatch@install

- name: Run static analysis
run: hatch fmt --check
Expand All @@ -59,9 +59,7 @@ jobs:
python-version: "3.8"

- name: Install Hatch
run: |
pip install --upgrade pip
pip install hatch
uses: pypa/hatch@install

- name: Update version
run: hatch version dev
Expand Down Expand Up @@ -114,7 +112,7 @@ jobs:
- name: Install QGIS
uses: crazy-max/ghaction-chocolatey@v3
with:
args: install qgis-ltr -y --version=3.28.14 # todo: remove version once python issue is fixed in newer versions
args: install qgis-ltr -y

- name: download whl
id: download-whl
Expand All @@ -125,11 +123,43 @@ jobs:
- name: Install qgis_venv_creator
run: pip install --no-index --find-links dist qgis_venv_creator

- name: Run tests
run: pytest tests --run-e2e -s

e2e-macos:
name: e2e - macOs
needs: [build]
runs-on: macos-latest
strategy:
fail-fast: false

steps:
- uses: actions/checkout@v4

- name: Install QGIS
run: |
brew install --cask qgis@ltr

- name: Set up Python ${{ env.STABLE_PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
cache: "pip"
python-version: ${{ env.STABLE_PYTHON_VERSION }}

- name: install pytest
run: |
pip install --upgrade pip
pip install pytest

- name: download whl
id: download-whl
uses: actions/download-artifact@v4
with:
name: ${{ needs.build.outputs.artifact-name }}

- name: Install qgis_venv_creator
run: pip install --no-index --find-links dist qgis_venv_creator

- name: Run tests
run: pytest tests --run-e2e -s

Expand Down Expand Up @@ -182,7 +212,7 @@ jobs:

post-artifact-comment:
name: Post artifact comment
needs: [unittest-formatting, build, e2e-linux, e2e-windows]
needs: [unittest-formatting, build, e2e-linux, e2e-windows, e2e-macos]
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
permissions:
Expand Down Expand Up @@ -214,7 +244,7 @@ jobs:

clear-artifact-comment-on-failure:
name: Clear artifact comment
needs: [unittest-formatting, build, e2e-linux, e2e-windows]
needs: [unittest-formatting, build, e2e-linux, e2e-windows, e2e-macos]
runs-on: ubuntu-latest
if: ${{ failure() && github.event_name == 'pull_request' }}
permissions:
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
}
},
"python.testing.pytestArgs": [
"tests"
"tests",
"--run-e2e"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
Expand Down
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
[![PyPI - Version](https://img.shields.io/pypi/v/qgis-venv-creator.svg)](https://pypi.org/project/qgis-venv-creator)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/qgis-venv-creator.svg)](https://pypi.org/project/qgis-venv-creator)
[![Tests and Style check](https://github.com/GispoCoding/qgis-venv-creator/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/GispoCoding/qgis-venv-creator/actions/workflows/test.yml)
[![Hatch project](https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg)](https://github.com/pypa/hatch)

---

Single file and zero dependency tool to create a Python virtual environment for QGIS plugin development.

Supports Windows, macOS and Linux.

**Table of Contents**

- [Installation](#installation)
Expand Down Expand Up @@ -48,7 +51,7 @@ $ create-qgis-venv

On a system where there might be multiple QGIS installations (ie. Windows, MacOs), you are asked to select the one you want to use for development.

After the virtual environment is created, you can activate it and it will have access to the QGIS Python environment.
After the virtual environment is created, you can activate it and it will have access to the PyQGIS API.

### Options

Expand All @@ -64,9 +67,9 @@ create-qgis-venv [-h] [--venv-parent VENV_PARENT] [--venv-name VENV_NAME]
| -h, --help | ALL | Show this help message and exit |
| --venv-parent | ALL | Path to the parent directory of the virtual environment to be created. Most likely your project directory. Default current directory. |
| --venv-name | ALL | Name of the virtual environment |
| --qgis-installation | Windows | Path to the QGIS installation to use for development. Installations made with official msi and Osgeo4W installers are supported. Give the path to the 'qgis' directory inside the 'apps' directory. If not given, the user is prompted to select one. |
| --qgis-installation-search-path-pattern | Windows | Custom glob pattern for QGIS installations to be selected. Can be set also with environment variable QGIS_INSTALLATION_SEARCH_PATH_PATTERN. For example "C:\\qgis\\\*\\apps\\qgis\*\\" to find installations from "C:\\qgis\\3.32\\apps\\qgis\\" and "C:\\qgis\\3.28\\apps\\qgis-ltr\\" |
| --python-executable | Windows | Path to the Python executable used by the QGIS installation. If not given, the Python executable is searched from the QGIS installation. |
| --qgis-installation | Windows, macOS | Path to the QGIS installation to use for development. Installations made with official msi and Osgeo4W installers are supported. Give the path to the 'qgis' directory inside the 'apps' directory. If not given, the user is prompted to select one. |
| --qgis-installation-search-path-pattern | Windows, macOS | Custom glob pattern for QGIS installations to be selected. Can be set also with environment variable QGIS_INSTALLATION_SEARCH_PATH_PATTERN. For example "C:\\qgis\\\*\\apps\\qgis\*\\" to find installations from "C:\\qgis\\3.32\\apps\\qgis\\" and "C:\\qgis\\3.28\\apps\\qgis-ltr\\" |
| --python-executable | Windows, macOS | Path to the Python executable used by the QGIS installation. If not given, the Python executable is searched from the QGIS installation. |
| --debug | ALL | Enable debug logging |

## Development
Expand All @@ -81,6 +84,20 @@ hatch config set dirs.env.virtual ".hatch"

After Hatch has created the environment, you can set your Python interpreter to use the one located in `.hatch/qgis-venv-creator`.

### Running tests

To run unittests run:

```console
hatch run test-cov
```

To run end-to-end tests run:

```console
hatch run test-e2e
```

### Pre-commit hook

This project uses [pre-commit](https://pre-commit.com/) to run code checks and tests before committing. You can install pre-commit with:
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dependencies = ["coverage[toml]>=6.5", "pytest", "mypy>=1.0.0"]

[tool.hatch.envs.default.scripts]
test = "pytest {args:tests}"
test-e2e = "pytest --run-e2e {args:tests}"
test-cov = "coverage run -m pytest {args:tests}"
cov-report = ["- coverage combine", "coverage report"]
cov = ["test-cov", "cov-report"]
Expand All @@ -57,6 +58,7 @@ python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
[tool.ruff]
extend = "ruff_defaults.toml"
target-version = "py38"
[tool.ruff.lint]
unfixable = [
"F401", # unused imports
"F841", # unused variables
Expand Down
35 changes: 29 additions & 6 deletions ruff_defaults.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ select = [
"B032",
"B033",
"B034",
"B035",
"B904",
"B905",
"BLE001",
Expand Down Expand Up @@ -83,7 +84,6 @@ select = [
"E101",
"E401",
"E402",
"E501",
"E701",
"E702",
"E703",
Expand Down Expand Up @@ -173,6 +173,10 @@ select = [
"INT002",
"INT003",
"ISC003",
"LOG001",
"LOG002",
"LOG007",
"LOG009",
"N801",
"N802",
"N803",
Expand All @@ -193,8 +197,6 @@ select = [
"PERF102",
"PERF401",
"PERF402",
"PGH001",
"PGH002",
"PGH005",
"PIE790",
"PIE794",
Expand All @@ -216,6 +218,7 @@ select = [
"PLE0116",
"PLE0117",
"PLE0118",
"PLE0237",
"PLE0241",
"PLE0302",
"PLE0307",
Expand Down Expand Up @@ -330,6 +333,7 @@ select = [
"PYI054",
"PYI055",
"PYI056",
"PYI058",
"RET503",
"RET504",
"RET505",
Expand All @@ -346,13 +350,15 @@ select = [
"RUF008",
"RUF009",
"RUF010",
"RUF011",
"RUF012",
"RUF013",
"RUF015",
"RUF016",
"RUF017",
"RUF018",
"RUF019",
"RUF020",
"RUF100",
"RUF200",
"S101",
"S102",
"S103",
Expand All @@ -364,6 +370,8 @@ select = [
"S110",
"S112",
"S113",
"S201",
"S202",
"S301",
"S302",
"S303",
Expand All @@ -387,7 +395,12 @@ select = [
"S323",
"S324",
"S501",
"S502",
"S503",
"S504",
"S505",
"S506",
"S507",
"S508",
"S509",
"S601",
Expand All @@ -398,8 +411,10 @@ select = [
"S607",
"S608",
"S609",
"S611",
"S612",
"S701",
"S702",
"SIM101",
"SIM102",
"SIM103",
Expand All @@ -409,6 +424,7 @@ select = [
"SIM109",
"SIM110",
"SIM112",
"SIM113",
"SIM114",
"SIM115",
"SIM116",
Expand All @@ -426,6 +442,7 @@ select = [
"SIM223",
"SIM300",
"SIM910",
"SIM911",
"SLF001",
"SLOT000",
"SLOT001",
Expand All @@ -438,17 +455,22 @@ select = [
"TCH003",
"TCH004",
"TCH005",
"TCH010",
"TD004",
"TD005",
"TD006",
"TD007",
"TID251",
"TID252",
"TID253",
"TRIO100",
"TRIO105",
"TRIO109",
"TRIO110",
"TRIO115",
"TRY002",
"TRY003",
"TRY004",
"TRY200",
"TRY201",
"TRY300",
"TRY301",
Expand Down Expand Up @@ -493,6 +515,7 @@ select = [
"UP038",
"UP039",
"UP040",
"UP041",
"W291",
"W292",
"W293",
Expand Down
Loading
Loading