Skip to content

Instantly share code, notes, and snippets.

@tonyseek
Created February 28, 2014 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonyseek/9266835 to your computer and use it in GitHub Desktop.
Save tonyseek/9266835 to your computer and use it in GitHub Desktop.
The wrapper for running wxPython in virtualenv.
#!/usr/bin/env sh
PYTHON_VERSION=2.7
WXPYTHON_ROOT="$(brew --prefix wxwidgets)/lib/python${PYTHON_VERSION}/site-packages"
WXPYTHON_SITE_ROOT="${WXPYTHON_ROOT}/$(cat ${WXPYTHON_ROOT}/wx.pth)"
SYSTEM_PYTHON=/usr/bin/python
# find the root of the virtualenv, it should be the parent of the dir this script is in
ENV=`${SYSTEM_PYTHON} -c "import os; print os.path.abspath(os.path.join(os.path.dirname(\"$0\"), '..'))"`
# now run Python with the virtualenv set as Python's HOME
export PYTHONPATH="${WXPYTHON_SITE_ROOT}:${PYTHONPATH}"
export PYTHONHOME="${ENV}"
exec $SYSTEM_PYTHON "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment