-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
77 lines (70 loc) · 2.87 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
require 'json'
require 'pathname'
require 'tmpdir'
# todo defaults must be fetched from bindlestiff installation later
name = File.exists?("settings.json") ? 'settings.json' : 'defaults.json'
$SETTINGS = JSON.parse(IO.read(name))
# Array of python interpreters to use (full semver string)
INTERPRETERS = $SETTINGS["INTERPRETERS"]
# Array of paths to projects you want to map into the boxes
$PROJECT_FOLDERS = $SETTINGS["PROJECT_FOLDERS"]
# path were the PROJECT_FOLDERS will be mpunted to
PROJECTS_MOUNT = $SETTINGS["PROJECT_MOUNT"]
# Name of the directory where tmp files will be stored in hosts tempdir
HOST_TMP_DIR = File.join(Dir.tmpdir(), "bindlestiff")
GUEST_TMP_DIR = "/home/vagrant/tmp"
PYENV_BIN_PATH = "/home/vagrant/.pyenv/bin"
def sync_folders(cnf)
# If externally mapped is to slow: add extra vdi or use different box
Dir.mkdir(HOST_TMP_DIR) unless File.exists?(HOST_TMP_DIR)
cnf.vm.synced_folder HOST_TMP_DIR, GUEST_TMP_DIR
$PROJECT_FOLDERS.each do |path|
if File.directory?(path) then
cnf.vm.synced_folder path,
File.join(PROJECTS_MOUNT, Pathname(path).basename),
:mount_options => ["rw"]
end
end
end
Vagrant.configure("2") do |config|
config.vm.define :lin do |lin|
lin.vm.box = "obestwalter/tox-dev-arch-linux"
lin.vm.provider "virtualbox" do |vb|
vb.memory = $SETTINGS["VB_MEMORY"]
end
sync_folders(lin)
# Install pyenv, python interpreters, activate them and install tox
installPyenvScript = <<-HEREDOC
export TMPDIR="#{GUEST_TMP_DIR}"
if [ -d "#{PYENV_BIN_PATH}" ]; then
#{PYENV_BIN_PATH}/pyenv update
else
sudo pacman --noconfirm -S base-devel openssl zlib git xz
curl pyenv.run | sh
sed -i '$ a\\export PATH="$HOME/.pyenv/bin:$PATH"' .bashrc
sed -i '$ a\\eval "$(pyenv init -)"' .bashrc
sed -i '$ a\\export TMPDIR="#{GUEST_TMP_DIR}"' .bashrc
sed -i '$ a\\cd #{PROJECTS_MOUNT}' .bashrc
fi
export PATH="#{PYENV_BIN_PATH}:$PATH"
eval "$(pyenv init -)"
echo #{INTERPRETERS.join(" ")}
for version in #{INTERPRETERS.join(" ")}; do
pyenv install -s $version
done
pyenv global #{INTERPRETERS.join(" ")}
pip install -U tox
# pytest fails with ImportMismatchError if we don't tidy up
find #{PROJECTS_MOUNT} -name '*.pyc' -delete
HEREDOC
lin.vm.provision "shell",
name: "install pyenv",
inline: installPyenvScript,
privileged: false
end
# No automation here yet, just the bare box wating to be configured ...
config.vm.define :win do |win|
win.vm.box = "inclusivedesign/windows10-eval"
sync_folders(win)
end
end