Skip to content

Commit 8b39741

Browse files
authored
ENH: Add qt and pyvista options (#7)
1 parent a90d08f commit 8b39741

File tree

5 files changed

+57
-12
lines changed

5 files changed

+57
-12
lines changed

.github/workflows/local.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,30 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
os: [macos-latest, ubuntu-latest, windows-2019, windows-2022]
20+
qt: [""]
21+
include:
22+
- os: ubuntu-latest
23+
qt: "qt"
2024
runs-on: ${{ matrix.os }}
2125
steps:
2226
- name: Checkout
2327
uses: actions/checkout@v2
2428

2529
- name: Test Action
2630
uses: ./
31+
with:
32+
qt: ${{ matrix.qt == 'qt' }}
2733

2834
- name: Setup Python
2935
uses: actions/setup-python@v1
3036
with:
31-
python-version: 3.9
37+
python-version: "3.9"
3238

3339
- name: Install PyVista
3440
run: pip install pyvista
3541

3642
- name: Test PyVista
37-
run: python test_pyvista.py
43+
run: python tests/test_pyvista.py
3844

3945
- uses: actions/upload-artifact@v2
4046
with:
@@ -44,6 +50,14 @@ jobs:
4450
- name: Second test of PyVista
4551
run: python -c "import pyvista;pyvista.Cube().plot(screenshot='${{ matrix.os }}-cube.png')"
4652

53+
- name: Test Qt
54+
if: matrix.qt == 'qt'
55+
run: |
56+
set -eo pipefail
57+
pip install PyQt6 matplotlib
58+
QT_DEBUG_PLUGINS=1 LIBGL_DEBUG=verbose python tests/test_qt.py
59+
shell: bash
60+
4761
- uses: actions/upload-artifact@v2
4862
with:
4963
name: cube

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ jobs:
3232
uses: pyvista/setup-headless-display-action@v1
3333
```
3434
35+
### Options
36+
37+
- `qt` (default `false`): set to `true` to install libraries required for Qt
38+
on Linux, e.g.:
39+
```yml
40+
- uses: pyvista/setup-headless-display-action@v1
41+
with:
42+
qt: true
43+
```
44+
- `pyvista` (default `true`): set to `false` if you don't want to set env
45+
vars to use PyVista in offscreen mode.
3546

3647
### 🖼️ PyVista Example
3748

action.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
name: 'setup-headless-display-action'
22
description: 'Setup a headless display on Linux and Windows'
33
author: PyVista Developers'
4+
inputs:
5+
pyvista:
6+
description: "Set PyVista env vars for headless mode"
7+
required: false
8+
default: true
9+
qt:
10+
description: "Install libraries required for Qt on Linux"
11+
required: false
12+
default: false
413
branding:
514
icon: 'monitor'
615
color: 'blue'
716
runs:
817
using: "composite"
918
steps:
10-
- name: Install Linux GL Dependencies
19+
20+
- name: Install Linux dependencies
1121
if: runner.os == 'Linux'
1222
shell: bash
13-
run: sudo apt-get update && sudo apt-get install libgl1-mesa-glx xvfb -y
23+
# TODO: Pyvista uses `xset` which is part of x11-xserver-utils, maybe a better way to check?
24+
run: sudo apt update && sudo apt install libgl1-mesa-glx xvfb x11-xserver-utils -y
25+
26+
- name: Install Linux Qt dependencies
27+
if: runner.os == 'Linux' && inputs.qt != 'false'
28+
shell: bash
29+
run: sudo apt install libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 libopengl0 libegl1 libosmesa6 mesa-utils libxcb-shape0
1430

1531
- name: Install Windows GL Dependencies
1632
if: runner.os == 'Windows'
@@ -28,19 +44,15 @@ runs:
2844
export DISPLAY=:99.0
2945
echo "DISPLAY=:99.0" >> $GITHUB_ENV
3046
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
31-
32-
- name: Give xvfb some time to start on Linux
33-
if: runner.os == 'Linux'
34-
shell: bash
35-
run: sleep 3
47+
sleep 3
3648
3749
- name: Configure for PyVista on Linux and macOS
38-
if: runner.os != 'Windows'
50+
if: runner.os != 'Windows' && inputs.pyvista != 'false'
3951
shell: bash
4052
run: echo "PYVISTA_OFF_SCREEN=true" >> $GITHUB_ENV
4153

4254
- name: Configure for PyVista on Windows
43-
if: runner.os == 'Windows'
55+
if: runner.os == 'Windows' && inputs.pyvista != 'false'
4456
shell: powershell
4557
run: |
4658
chcp 65001 #set code page to utf-8
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
"""Quickly check if VTK off screen plotting works."""
2+
from pathlib import Path
23
import pyvista
34
from pyvista.plotting import system_supports_plotting
45

56
print(f'system_supports_plotting: {system_supports_plotting()}')
67
assert system_supports_plotting()
78
# pyvista.OFF_SCREEN = True # should be set by Action in Env
89
sphere = pyvista.Sphere()
9-
pyvista.plot(sphere, screenshot='sphere.png')
10+
out_path = Path(__file__).parent / '..' / 'sphere.png'
11+
pyvista.plot(sphere, screenshot=out_path)

tests/test_qt.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import matplotlib
2+
matplotlib.use('QtAgg')
3+
import matplotlib.pyplot as plt
4+
plt.figure()
5+
backend = matplotlib.get_backend()
6+
assert backend == 'QtAgg', backend

0 commit comments

Comments
 (0)