Skip to content

Commit 28a70ec

Browse files
committed
fix(installer): prioritize user-installed packages over server-libs
Change sys.path.insert(0, ...) to sys.path.append(...) for server site-packages so user-installed packages in system site-packages take precedence over bundled server-libs packages. Previously, server-libs were inserted at the front of sys.path, causing bundled versions to override user-installed versions (e.g., streamlit).
1 parent c0b20f3 commit 28a70ec

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

installer/module/virtual_environment.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ def import_package_bundle(
9696
if condition_env:
9797
# Write conditional import that checks environment variable
9898
pth_content = (
99-
f"import os, sys; "
100-
f"sys.path.append('{bundle_site_package_path}') "
99+
f"import sys, os, sysconfig; "
100+
f"(sys.path.append('{bundle_site_package_path}'), "
101+
f"sys.path.insert(sys.path.index('{bundle_site_package_path}'), sysconfig.get_path('purelib'))) "
101102
f"if os.environ.get('{condition_env}', '').lower() == 'true' else None"
102103
)
103104
pth_file.write(pth_content + "\n")

0 commit comments

Comments
 (0)