Skip to content

Commit 380e844

Browse files
authored
PR: Prevent to add site-packages directories placed inside AppData ones to the Pythonpath manager (#23668)
1 parent 302b3a5 commit 380e844

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Diff for: spyder/plugins/pythonpath/tests/test_utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def test_check_path(tmp_path):
2828
assert not check_path('lib\\dist-packages')
2929
assert not check_path('Lib/site-packages')
3030
assert not check_path('Anaconda3/pkgs')
31+
assert not check_path("C:\\Users\\user\\AppData\\Roaming\\Python\\Scripts")
3132
else:
3233
# One digit Python versions
3334
assert not check_path('lib/python3.9/site-packages')

Diff for: spyder/plugins/pythonpath/utils.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ def check_path(path):
2222
"""
2323
pattern_string = r'(ana|mini|micro)(conda|mamba|forge)\d*(/base)*/pkgs'
2424
if os.name == 'nt':
25+
path_appdata = os.getenv("APPDATA").replace('\\', '/')
2526
pattern_string = (
2627
f'.*({pattern_string}'
27-
r'|(l|L)ib/(site|dist)-packages).*'
28+
r'|(l|L)ib/(site|dist)-packages.*'
29+
f'|(AppData|{path_appdata})/Roaming/Python).*'
2830
)
2931
else:
3032
pattern_string = (

0 commit comments

Comments
 (0)