forked from pyvista/pyvista
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtoxfile.py
More file actions
41 lines (31 loc) · 1.44 KB
/
Copy pathtoxfile.py
File metadata and controls
41 lines (31 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from __future__ import annotations # noqa: D100
import os
import re
from typing import TYPE_CHECKING
from packaging.version import Version
from tox.plugin import impl
if TYPE_CHECKING:
from tox.config.sets import EnvConfigSet
from tox.session.state import State
@impl
def tox_add_env_config(env_conf: EnvConfigSet, state: State) -> None: # noqa: ARG001, D103
if os.environ.get('CI', 'false').lower() != 'true':
return
if env_conf.env_name in ['docs-build', 'doctest-modules']:
env_conf['set_env'].update({'VTK_DEFAULT_OPENGL_WINDOW': 'vtkEGLRenderWindow'})
return
# For plotting tests on Linux with vtk < 9.4, some segfaults have been spotted
# See https://github.com/pyvista/pyvista/pull/7885#issuecomment-3263323390
# Therefore, the "PARALLEL" env variable is updated
if ('plotting' in env_conf.name) and os.environ['RUNNER_OS'] == 'Linux':
# Test the vtk version from TOX_FACTOR env variable
reg = re.compile('.*-vtk_(.*)$')
if not (factor := os.environ.get('TOX_FACTOR')):
return
if not (m := re.match(reg, factor)):
msg = 'The `TOX_FACTOR` env variable is malformed. Could not get the vtk version.'
raise ValueError(msg)
vtk_version = m.group(1)
val = '-n4' if vtk_version == 'latest' or Version(vtk_version) >= Version('9.4.0') else ''
updated = {'PARALLEL': val}
env_conf['set_env'].update(updated)