Skip to content

Commit

Permalink
PR: Prevent to add site-packages directories placed inside `AppData…
Browse files Browse the repository at this point in the history
…` ones to the Pythonpath manager (#23668)
  • Loading branch information
jsbautista authored Feb 10, 2025
1 parent 302b3a5 commit 380e844
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions spyder/plugins/pythonpath/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def test_check_path(tmp_path):
assert not check_path('lib\\dist-packages')
assert not check_path('Lib/site-packages')
assert not check_path('Anaconda3/pkgs')
assert not check_path("C:\\Users\\user\\AppData\\Roaming\\Python\\Scripts")
else:
# One digit Python versions
assert not check_path('lib/python3.9/site-packages')
Expand Down
4 changes: 3 additions & 1 deletion spyder/plugins/pythonpath/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ def check_path(path):
"""
pattern_string = r'(ana|mini|micro)(conda|mamba|forge)\d*(/base)*/pkgs'
if os.name == 'nt':
path_appdata = os.getenv("APPDATA").replace('\\', '/')
pattern_string = (
f'.*({pattern_string}'
r'|(l|L)ib/(site|dist)-packages).*'
r'|(l|L)ib/(site|dist)-packages.*'
f'|(AppData|{path_appdata})/Roaming/Python).*'
)
else:
pattern_string = (
Expand Down

0 comments on commit 380e844

Please sign in to comment.