Created
February 3, 2023 12:34
-
-
Save stuaxo/71b186c335ea88b8ecdde48609a78ecb to your computer and use it in GitHub Desktop.
Update sys.path if PYTHONPATH is changed by dotenv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update_paths(): | |
import os | |
import sys | |
import dotenv | |
dotenv.load_dotenv(override=True) | |
new_paths = {*os.environ["PYTHONPATH"].split(":")} - set(sys.path) | |
sys.path.extend(new_paths) | |
return new_paths |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment