Created
February 23, 2017 13:42
-
-
Save ntpz/21d2d7ff4e6430bd33bf4ada84ce51e9 to your computer and use it in GitHub Desktop.
Set up python dev environment on Cloud9
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 | |
cd ~/workspace | |
# Upgrade pip | |
wget https://bootstrap.pypa.io/get-pip.py | |
sudo -H python get-pip.py | |
sudo -H python3 get-pip.py | |
# Install python packages | |
sudo -H pip install --upgrade virtualenvwrapper pep8 autopep8 autoenv bpython readline pip-tools | |
sudo -H pip3 install --upgrade virtualenvwrapper pep8 autopep8 autoenv bpython readline pip-tools | |
# Cleanup | |
rm -rf README.md ex50 get-pip.py | |
cat <<EOT >> ~/.bashrc | |
# virtualenvwrapper stuff | |
export WORKON_HOME=$HOME/.virtualenvs | |
export PROJECT_HOME=$HOME/workspace | |
source /usr/local/bin/virtualenvwrapper.sh | |
# avoid .pyc files | |
export PYTHONDONTWRITEBYTECODE=1 | |
# activate autoenv hook | |
source /usr/local/bin/activate.sh | |
# Python interactive startup file | |
export PYTHONSTARTUP="$HOME/.pystartup" | |
EOT | |
cat <<EOT > ~/.pystartup | |
# Add auto-completion and a stored history file of commands to your Python | |
# interactive interpreter. Requires Python 2.0+, readline. Autocomplete is | |
# bound to the Esc key by default (you can change it - see readline docs). | |
# | |
# Store the file in ~/.pystartup, and set an environment variable to point | |
# to it: "export PYTHONSTARTUP=~/.pystartup" in bash. | |
import atexit | |
import os | |
import sys | |
import readline | |
import rlcompleter | |
historyPath = os.path.expanduser("~/.pyhistory") | |
def save_history(historyPath=historyPath): | |
import readline | |
readline.write_history_file(historyPath) | |
if os.path.exists(historyPath): | |
readline.read_history_file(historyPath) | |
atexit.register(save_history) | |
readline.parse_and_bind("tab: complete") | |
del atexit, readline, rlcompleter, save_history, historyPath | |
EOT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment