summaryrefslogtreecommitdiff
path: root/helpers.py
blob: faf14e7b5201b5c7795d640fa6a76cd47aa6ab6a (plain)
1
2
3
4
5
6
7
8
9
from os import path
from pathlib import Path


def relative_path(*, to, ref):
    # pathlib.Path(x).relative_to(y) cannot handle y not being under x,
    # os.path.dirname('x') yields '' rather than '.'.
    # 😮‍💨
    return path.relpath(to, Path(ref).parent)