Pip, Python’s package manager has a hard time changing whrere stuff is but I finally got something that works.
XDG_CACHE_DIR=cache PIP_CACHE_DIR=cache TMPDIR=cache pip --cache-dir=cache install ...
Boy that’s quite a mouthful but it’s mostly applied.