Skip to content

Instantly share code, notes, and snippets.

@pmgupte
Created March 23, 2017 05:22
Show Gist options
  • Save pmgupte/6f2623d8ff4a00379add22e89a21f986 to your computer and use it in GitHub Desktop.
Save pmgupte/6f2623d8ff4a00379add22e89a21f986 to your computer and use it in GitHub Desktop.
Python code to dynamically add .egg files to sys.path
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