Skip to content

Instantly share code, notes, and snippets.

@holtgrewe
Last active June 9, 2022 14:49
Show Gist options
  • Save holtgrewe/f4575f2f871bbe46e00b65fb5227b1d9 to your computer and use it in GitHub Desktop.
Save holtgrewe/f4575f2f871bbe46e00b65fb5227b1d9 to your computer and use it in GitHub Desktop.
Setup varfish-server development in WSL2 (Ubuntu 22.04 LTS)

The setup was done on a recent version of Windows 10 with Windows Subsystem for Linux Version 2 (WSL2).

First, install WSL 2, e.g., following this tutorial

  • Note that the whole thing appears to be a bit convoluted, you start out with wsl.exe --install
  • Then you can install latest LTS Ubuntu 22.04 with the Microsoft Store
  • Once complete, you probably end up with a WSL 1 (one!) that you can conver to version 2 (two!) with wsl --set-version Ubuntu-22.04 2 or similar.
  • WSL2 has some advantages including running a full Linux kernel but is even slower in I/O to the NTFS Windows mount.
  • Everything that you do will be inside the WSL image.

Second, you install the development dependencies such as installing postgres and redis inside WSL2.

$ sudo apt install libsasl2-dev python3-dev libldap2-dev libssl-dev gcc make rsync
$ sudo apt install postgresql postgresql-server-dev-14 postgresql-client redis
$ sudo service postgresql start
$ sudo service postgresql status
$ sudo service redis-server start
$ sudo service redis-server status
$ sudo sed -i -e 's/.*max_locks_per_transaction.*/max_locks_per_transaction = 1024 # min 10/' /etc/postgresql/14/main/postgresql.conf
$ sudo service postgresql restart

Create a postgres user varfish with password varfish and a database.

$ sudo -u postgres createuser -s -r -d varfish -P
[enter varfish as password]
$ sudo -u postgres createdb --owner=varfish varfish

Create a miniconda3 installation with an environment

$ mkdir -p Development Downloads
$ cd Downloads
$ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
$ bash Miniconda3-latest-Linux-x86_64.sh -b -p ~/miniconda3
$ source ~/miniconda3/bin/activate
$ conda install -y mamba
$ mamba create -y -n varfish-server python==3.9 nodejs=12
$ conda activate varfish-server

Finally, checkout varfish-server and create a development .env file:

$ cd ~/Development
$ git clone git@github.com:bihealth/varfish-server.git
$ cat <<"EOF" >.env
export VARFISH_ENABLE_SPANR_SUBMISSION=1
export VARFISH_ENABLE_CADD_SUBMISSION=1
export VARFISH_ENABLE_SPANR_SUBMISSION=1

export VARFISH_ENABLE_SVS=1
export DJANGO_SETTINGS_MODULE=config.settings.local
export DJANGO_SECURE_SSL_REDIRECT=0

export DJANGO_SECRET_KEY="0Vabi8RKYcSgVTGhr23AlIFA5D1aXh25ZBvxXi9Tgu9UrrFdiolaQchS9k7CfqIMev7KoLV2RH84XxQDcDCmIoeyVmMmNUh7jE8N"
export DATABASE_URL="postgres://varfish:varfish@127.0.0.1/varfish"

export VARFISH_ENABLE_BEACON_SITE=1
export FIELD_ENCRYPTION_KEY=_XRAzgLd6NHj8G4q9FNV0p3Um9g4hy8BPBN-AL0JWO0=
EOF
$ make test-noselenium

Third, you open the project in the WSL image in PyCharm.

This has been tested with PyCharm Professional only (I don't know whether it works with the community edition...)

  • You can simply open projects in the WSL, e.g., \\wsl$Ubuntu-22.04\home....
  • You can add the interpreter in the varfish-server miniconda3 environment to PyCharm which gives you access to

How well does it work? "It seems to work", I will write more once I have experience.

-- June 9, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment