Skip to content

Commit df02efe

Browse files
committed
Use "agg" matplotlib backend on GHA/Windows
Avoid TCL errors possibly due to python/cpython#125235 and/or astral-sh/uv#7036.
1 parent fda4eaf commit df02efe

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

message_ix/testing/__init__.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import io
22
import os
3+
import platform
34
from collections.abc import Callable, Generator
45
from itertools import product
56
from pathlib import Path
@@ -28,12 +29,21 @@
2829
def pytest_configure(config: pytest.Config) -> None:
2930
"""Force iam-units to use a distinct cache for each worker.
3031
31-
Work around for https://github.com/hgrecco/flexcache/issues/6 /
32-
https://github.com/IAMconsortium/units/issues/54.
32+
Work arounds for:
33+
34+
1. https://github.com/hgrecco/flexcache/issues/6 /
35+
https://github.com/IAMconsortium/units/issues/54.
36+
2. https://github.com/python/cpython/issues/125235,
37+
https://github.com/astral-sh/uv/issues/7036, or similar.
3338
"""
3439
name = f"iam-units-{os.environ.get('PYTEST_XDIST_WORKER', '')}".rstrip("-")
3540
os.environ["IAM_UNITS_CACHE"] = str(config.cache.mkdir(name))
3641

42+
if GHA and platform.system() == "Windows":
43+
import matplotlib
44+
45+
matplotlib.use("agg")
46+
3747

3848
def pytest_report_header(config: pytest.Config, start_path: Path) -> str:
3949
"""Add the message_ix import path to the pytest report header."""

0 commit comments

Comments
 (0)