Created
March 23, 2017 05:22
-
-
Save pmgupte/6f2623d8ff4a00379add22e89a21f986 to your computer and use it in GitHub Desktop.
Python code to dynamically add .egg files to sys.path
This file contains 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
import sys | |
import os | |
""" | |
dynamically load all the .egg files. | |
Put all your .egg files in a directory named "eggs". | |
Following code will add all of them to sys.path, | |
so that you can import from those .egg files directly. | |
""" | |
SCRIPT_DIR = os.path.realpath(__file__) | |
EGG_DIR = SCRIPT_DIR + "/eggs/" | |
for filename in os.listdir(EGG_DIR): | |
if filename.endswith(".egg"): | |
sys.path.append(EGG_DIR + filename) | |
""" | |
Now, you are ready to import modules from .egg files. | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment