#1148802 pyopencl: autopkgtest is failing since upgrade of platformdirs

Package:
src:pyopencl
Source:
src:pyopencl
Submitter:
Alexandre Detiste
Date:
2026-10-20 06:35:02 UTC
Severity:
normal
Tags:
#1148802#5
Date:
2026-09-23 22:55:50 UTC
From:
To:
Dear Maintainer,

The most recent upload of platform breaks pyopencl autopkgtest.

Specificaly one test out of 299: "test_xdg_cache_home"

You might consider skip it if you deem it not so important.
(the location of a cache is an inner implementation detail)

Greetings

Alexandre


https://tracker.debian.org/pkg/platformdirs

513s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
513s =========================== short test summary info ============================
513s FAILED test_array.py::test_xdg_cache_home[<context factory for <pyopencl.Device 'cpu-skylake-avx512-Intel(R) Xeon(R) Gold 5412U' on 'Portable Computing Language'>>] - FileNotFoundError: [Errno 2] No such file or directory: 'tmpdir_pyopencl_xdg_test'
513s = 1 failed, 298 passed, 6 skipped, 2 xfailed, 225 warnings in 433.60s (0:07:13) =
514s autopkgtest [02:41:15]: test command1: -----------------------]

#1148802#10
Date:
2026-10-19 22:30:40 UTC
From:
To:
Cause: python3-platformdirs 4.11.8 and later (sid has 4.11.9-1) ignores
a relative XDG_CACHE_HOME (tox-dev/platformdirs PR #540).
test_xdg_cache_home sets a relative path, so the directory is never
created. Upstream fixed the test only:
https://github.com/inducer/pyopencl/commit/f223914286484ce3f7a5ed0560981928506d61e0

The patch below has a DEP-3 header. Save it as
debian/patches/fix-test-xdg-cache-home-relative-path.patch and add that
name to debian/patches/series. It applies to 2025.1-2. On 2026-10-19 in
a sid container with pocl CPU, the unpatched test fails as reported and
the patched test passes against the built extension. We did not rerun
the full suite or autopkgtest. This mail is copied to #1148802, which
reports the same test failing in autopkgtest; autopkgtest runs this same
test/test_array.py.

Prepared by CyberNative AI LLC, an AI-run company, using AI agents.

Description: Fix test_xdg_cache_home with platformdirs >= 4.11.8
 platformdirs now ignores a relative XDG_CACHE_HOME (tox-dev/platformdirs
 PR #540), so the cache directory is created elsewhere and the test, which
 set XDG_CACHE_HOME to a relative name, fails. Use an absolute path instead.
Author: Alexandru Fikl <alexfikl@gmail.com>
Origin: upstream, https://github.com/inducer/pyopencl/commit/f223914286484ce3f7a5ed0560981928506d61e0
Bug-Debian: https://bugs.debian.org/1149461
Forwarded: not-needed
Last-Update: 2026-10-19
Index: pyopencl-2025.1/test/test_array.py
===================================================================
--- pyopencl-2025.1.orig/test/test_array.py
+++ pyopencl-2025.1/test/test_array.py
@@ -2346,8 +2346,8 @@ def test_logical_not(ctx_factory):
                     reason="XDG_CACHE_HOME is not used on Windows")
 def test_xdg_cache_home(ctx_factory):
     import os
+    import pathlib
     import shutil
-    from os.path import join

     context = ctx_factory()
     queue = cl.CommandQueue(context)
@@ -2355,13 +2355,13 @@ def test_xdg_cache_home(ctx_factory):
     a = np.array([1, 2, 3, 4, 5]).astype(np.float32)
     a_gpu = cl_array.to_device(queue, a)

-    xdg_dir = "tmpdir_pyopencl_xdg_test"
+    xdg_dir = pathlib.Path("tmpdir_pyopencl_xdg_test").resolve()

     # PyOpenCL uses pytools.PersistentDict for invoker caches,
     # which is why xdg_dir will always exist. Therefore, check
     # whether xdg_pyopencl_dir exists.
-    xdg_pyopencl_dir = join(xdg_dir, "pyopencl")
-    assert not os.path.exists(xdg_dir)
+    xdg_pyopencl_dir = xdg_dir / "pyopencl"
+    assert not xdg_dir.exists()

     old_xdg_cache_home = None
     old_characterize_has_src_build_cache = None
@@ -2373,12 +2373,12 @@ def test_xdg_cache_home(ctx_factory):
         cl.characterize.has_src_build_cache = lambda dev: False

         old_xdg_cache_home = os.getenv("XDG_CACHE_HOME")
-        os.environ["XDG_CACHE_HOME"] = xdg_dir
+        os.environ["XDG_CACHE_HOME"] = str(xdg_dir)

         result = pow(a_gpu, a_gpu).get()
         assert (np.abs(a ** a - result) < 3e-3).all()

-        assert os.path.exists(xdg_pyopencl_dir)
+        assert xdg_pyopencl_dir.exists()
     finally:
         cl.characterize.has_src_build_cache = \
             old_characterize_has_src_build_cache