Skip to content

Instantly share code, notes, and snippets.

@saboyutaka
Created January 11, 2017 03:34
Show Gist options
  • Save saboyutaka/c4dd82976585587d0e7591e9ba6ea06f to your computer and use it in GitHub Desktop.
Save saboyutaka/c4dd82976585587d0e7591e9ba6ea06f to your computer and use it in GitHub Desktop.
For Python3 environment
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network :forwarded_port, guest: 5000, host: 5000
config.vm.network :forwarded_port, guest: 8888, host: 8888
config.vm.synced_folder ".", "/vagrant"
GUEST_PYTHON_VERSION = '3.5.2'
# 必要なパッケージをインストール
config.vm.provision "shell", privileged: true, inline: <<-__SCRIPT__
export DEBIAN_FRONTEND=noninteractive
apt-get update -y
# develop env
apt-get install -y make git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev debconf-utils libbz2-dev llvm libsqlite3-dev
# lib for NumPy、SciPy、matplotlib
apt-get install -y libfreetype6-dev libblas-dev liblapack-dev gfortran tk-dev
# Set timezone
cp /usr/share/zoneinfo/Japan /etc/localtime
__SCRIPT__
# Python, Jupyter notebook
config.vm.provision "shell", privileged: false, inline: <<-__SCRIPT__
git clone https://github.com/yyuu/pyenv ~/.pyenv
echo "alias ls='ls --color=auto'" ~/.bash_profile
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
#{defined?(GUEST_PYTHON_VERSION) ? "pyenv install %s; pyenv global %s;" % [GUEST_PYTHON_VERSION, GUEST_PYTHON_VERSION] : ''}
pip install numpy ipython jupyter flask
jupyter notebook --generate-config
echo "c.NotebookApp.ip = '*'" >> ~/.jupyter/jupyter_notebook_config.py
echo "c.NotebookApp.notebook_dir = '/vagrant'" >> ~/.jupyter/jupyter_notebook_config.py
echo "c.NotebookApp.open_browser = False" >> ~/.jupyter/jupyter_notebook_config.py
__SCRIPT__
config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"
config.vm.provider "virtualbox" do |vb|
vb.memory = ENV["VM_MEMORY"] || "1024"
vb.customize ["setextradata", :id, "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled", 0]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment