From 1936ed6b7251bfc0545e11aacfd22e906f306585 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Sun, 11 Jun 2023 14:52:00 -0500 Subject: [PATCH] Fix error in Conda environments that use Python 3.10 --- pylint_venv.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pylint_venv.py b/pylint_venv.py index ff4fb32..1ecd814 100644 --- a/pylint_venv.py +++ b/pylint_venv.py @@ -86,6 +86,10 @@ def activate_venv(venv): else: lib_dir = os.path.join(venv, "lib") python_dirs = [d for d in os.listdir(lib_dir) if re.match(r"python\d+.\d+", d)] + + # Resolve symlinks and remove repeated directories + python_dirs = set([os.path.realpath(os.path.join(lib_dir, d)) for d in python_dirs]) + if len(python_dirs) == 0: raise IncompatibleVenvError( f"The virtual environment {venv!r} is missing a lib/pythonX.Y directory." @@ -94,7 +98,7 @@ def activate_venv(venv): raise IncompatibleVenvError( f"The virtual environment {venv!r} has multiple lib/pythonX.Y directories." ) - site_packages = os.path.join(lib_dir, python_dirs[0], "site-packages") + site_packages = os.path.join(list(python_dirs)[0], "site-packages") prev = set(sys.path) site.addsitedir(site_packages)