From 096906efb869bcf4d88f197a79fee00d39bf7640 Mon Sep 17 00:00:00 2001 From: Seunghoon Lee Date: Wed, 18 Dec 2024 20:51:25 +0900 Subject: [PATCH] relpath fails when venv is in different drive --- installer.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/installer.py b/installer.py index 2bb3df492..c0d3c907d 100644 --- a/installer.py +++ b/installer.py @@ -1177,9 +1177,15 @@ def check_ui(ver): def check_venv(): + def try_relpath(p): + try: + return os.path.relpath(p) + except ValueError: + return p + import site - pkg_path = [os.path.relpath(p) for p in site.getsitepackages() if os.path.exists(p)] - log.debug(f'Packages: venv={os.path.relpath(sys.prefix)} site={pkg_path}') + pkg_path = [try_relpath(p) for p in site.getsitepackages() if os.path.exists(p)] + log.debug(f'Packages: venv={try_relpath(sys.prefix)} site={pkg_path}') for p in pkg_path: invalid = [] for f in os.listdir(p):