Skip to content

Commit

Permalink
Always add bundled directory to front of path (#230)
Browse files Browse the repository at this point in the history
I guess it's, like, _possible_ that some users already have the bundled
library in their `sys.path`? There's no harm in adding it again, we want
it to be at the front.
  • Loading branch information
charliermarsh committed Jun 17, 2023
1 parent 73a725c commit 66b49c2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions bundled/tool/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
logger = logging.getLogger(__name__)


# Update sys.path before importing any bundled libraries.
def update_sys_path(path_to_add: str) -> None:
"""Add given path to `sys.path`."""
if path_to_add not in sys.path and os.path.isdir(path_to_add):
# site adds the directory at the end if it is not yet present, we want it to
# be front
if os.path.isdir(path_to_add):
# The `site` module adds the directory at the end, if not yet present; we want
# it to be at the beginning, so that it takes precedence over any other
# installed versions.
sys.path.insert(0, path_to_add)
# Allow dev installs into bundled/libs

# Allow development versions of libraries to be imported.
site.addsitedir(path_to_add)


Expand Down

0 comments on commit 66b49c2

Please sign in to comment.