Created
March 22, 2019 11:46
-
-
Save vladimir-kotikov/09649350029b2eb333ba503fa9ad141b to your computer and use it in GitHub Desktop.
Python interpreter shim for vscode python remote debug
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
#!/bin/bash | |
set -o errexit -o pipefail -o noclobber -o nounset | |
# VSCode runs this when starting local debug: | |
# env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /Users/kotikov.vladimir/repos/reddit/snoovatar/.venv/bin/python /Users/kotikov.vladimir/.vscode/extensions/ms-python.python-2019.2.5558/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 54077 /Users/kotikov.vladimir/repos/reddit/snoovatar/snoovatar/__init__.py | |
FILENAME="${1##*/}" | |
if [ "$FILENAME" == "interpreterInfo.py" ]; then | |
python3 "$1" | |
exit 0 | |
fi | |
# Shift script path and ptvs launcher args | |
shift 3 | |
# Find out ptvsd port | |
OPTS= | |
while [[ $# -gt 0 ]]; do | |
case "$1" in | |
--port) | |
PORT="$2" | |
OPTS="$OPTS $1 $2" | |
shift | |
shift | |
;; | |
*) | |
OPTS="$OPTS $1" | |
shift | |
;; | |
esac | |
done | |
PTVSD=https://files.pythonhosted.org/packages/e8/49/d56614d374f7c0e88bb255057cba0bf0d10a7e94cf5792def97ac6c1d8da/ptvsd-4.2.4.zip | |
PYTHON=python | |
SRC_ROOT=src/snoovatar | |
SSH_ARGS="reddit" | |
ssh $SSH_ARGS \ | |
"cd $SRC_ROOT>/dev/null; \ | |
$PYTHON -u -c \"import ptvsd\">/dev/null || (echo installing ptvsd && $PYTHON -m pip install $PTVSD)" | |
ssh -L 127.0.0.1:$PORT:127.0.0.1:$PORT $SSH_ARGS \ | |
"cd $SRC_ROOT>/dev/null; \ | |
PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 GEVENT_SUPPORT=True $PYTHON -m ptvsd $OPTS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment