[go: up one dir, main page]

Menu

[5feb5c]: / Vagrantfile  Maximize  Restore  History

Download this file

158 lines (133 with data), 7.2 kB

  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
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
config.vm.box = "debian/bookworm64"
config.vm.box_check_update = true
# Forwards port 8888 in the guest VM (used by default by the Jupyter notebook)
# to port 18888 on the localhost interface in the host.
config.vm.network "forwarded_port", guest: 8888, host: 18888, host_ip: "127.0.0.1"
# -------------------------------------------
# Begin Settings that you may want to change
# -------------------------------------------
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "c:/users/lu/wavepacket_shared", "/home/vagrant/shared", create: true
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# Customize the name of the virtual machine
vb.name = "wavepacket"
# Customize the amount of memory on the VM (Megabytes)
# Most people can easily assign ca. half of their memory here
vb.memory = "2048"
# Customize the number of CPUs available for the VM:
vb.cpus = 2
end
# ----------------------------------------
# End settings that you may want to change
# ----------------------------------------
# Sample customization for HyperV
# See the VirtualBox example for comments
config.vm.provider "hyperv" do |h|
h.vmname = "wavepacket"
h.maxmemory = 2048
h.cpus = 2
end
# Enable provisioning with a shell script. Additional provisioners such as
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", privileged: false, inline: <<-SHELL
# This script doubles as a building Howto. It should provide a comprehensive
# walkthrough for building Wavepacket with minimal modifications on
# essentially any (Unix) system.
#
# Windows has different tools, but the basic command sequence should be the same.
#
# Installing all packages instead of building them would be simpler, but I
# deliberately traded simplicity for readability here.
# 0. Install all required packages
sudo apt-get -y update
sudo apt-get -y install git curl zip unzip pkg-config
sudo apt-get -y install g++ gfortran cmake make
sudo apt-get -y install python3 python3-venv python3-dev
sudo apt-get -y install gnuplot imagemagick ffmpeg # for plotting and the like
# 1. Set some basic variables
SRC_ROOT=/home/vagrant/src # where we download all sources
BUILD_ROOT=/home/vagrant/build # where we build the software
INSTALL_ROOT=/home/vagrant/install # where we put everything
VENV_ROOT=${INSTALL_ROOT}/venv # Python virtual environment;
# will be used for running wavepacket
mkdir -p ${SRC_ROOT}
mkdir -p ${BUILD_ROOT}
mkdir -p ${INSTALL_ROOT}
# 2. Download all sources
# We need a particular version of the tensor library, there is a rewrite going on.
git clone https://github.com/microsoft/vcpkg ${SRC_ROOT}/vcpkg
git clone https://github.com/juanjosegarciaripoll/tensor ${SRC_ROOT}/tensor
git -C ${SRC_ROOT}/tensor checkout 9f46d55
# Wavepacket does not need to be cloned. As you have this Vagrantfile, you already have
# a copy of the source code. The directory containing this Vagrantfile is mounted under /vagrant
# git clone https://git.code.sf.net/p/wavepacket/cpp/git ${SRC_ROOT}/wavepacket
# 3. Install all required vcpkg packages
cd ${SRC_ROOT}/vcpkg
bash bootstrap-vcpkg.sh
./vcpkg install fftw3 blas lapack
./vcpkg install gtest
# Here we chicken out: boost is such a huge, complex beast that we just use the system lib
sudo apt-get -y install libboost-dev
# We need a reasonably modern CMake for Wavepacket and the tensor lib.
# Use the one from vcpkg
CMAKE=${SRC_ROOT}/vcpkg/downloads/tools/cmake*/cmake*/bin/cmake
# 4. Build and install the tensor library
# We need to edit the CMakeLists.txt manually because it does not cover
# all the silly names that Lapack libraries can have.
sed -i -r 's/IMPORT_TARGET LAPACK::LAPACK/IMPORT_TARGET lapack/' ${SRC_ROOT}/tensor/CMakeLists.txt
sed -i -r 's/CONFIG_NAMES LAPACK/CONFIG_NAMES lapack/' ${SRC_ROOT}/tensor/CMakeLists.txt
# Crude, but correct place
sed -i -r 's/# Fortran name mangling/set(tensor_lapack_target ${tensor_lapack_target} -lgfortran)/' \
${SRC_ROOT}/tensor/CMakeLists.txt
${CMAKE} -S ${SRC_ROOT}/tensor -B ${BUILD_ROOT}/tensor \
-D TENSOR_FFTW=ON -D BUILD_SHARED_LIBS=ON \
-D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=${INSTALL_ROOT} \
-D CMAKE_PREFIX_PATH=${SRC_ROOT}/vcpkg/installed/x64-linux
make -C ${BUILD_ROOT}/tensor -j 2
make -C ${BUILD_ROOT}/tensor install
# you could optionally run the tests:
# cd ${BUILD_ROOT}/tensor/tests && ctest
# 5. Install the Python venv.
# We can also use it later for running Wavepacket and the like.
python3 -m venv ${VENV_ROOT}
sudo apt-get -y install libcairo2-dev libgirepository1.0-dev
${VENV_ROOT}/bin/pip3 install -r /vagrant/python/requirements.txt
# 6. Build and install Wavepacket
${CMAKE} -S /vagrant -B ${BUILD_ROOT}/wavepacket \
-D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=${INSTALL_ROOT} \
-D CMAKE_PREFIX_PATH="${SRC_ROOT}/vcpkg/installed/x64-linux;${INSTALL_ROOT}" \
-D Python3_ROOT=${VENV_ROOT}
make -C ${BUILD_ROOT}/wavepacket -j 2
make -C ${BUILD_ROOT}/wavepacket install
# You could optionally run the tests
# cd ${BUILD_ROOT}/wavepacket && ctest
################################################################
# And done
################################################################
# The remainder of this script sets up a Jupyter notebook such that you can
# play around with your browser.
${VENV_ROOT}/bin/pip3 install pytest notebook
# export the path to the Wavepacket Python module
# and a shortcut for the notebook call
echo -e "\nexport PYTHONPATH=${INSTALL_ROOT}/lib/wavepacket_python\n" >> /home/vagrant/.profile
echo "alias notebook='${VENV_ROOT}/bin/python3 -m notebook --NotebookApp.token= --ip=0.0.0.0'" >> /home/vagrant/.profile
SHELL
end