-
Notifications
You must be signed in to change notification settings - Fork 0
Development Workstation setup
This file provides instructions to setup a suitable development environment for this project and run the flask app in it. We consider 4 options;
- Run on Linux natively or inside a Linux virtual Box
- Run on Windows natively
- Run on Windows using the Windows Subsystem for Linux
If you are not going to run native on Linux, first do the following;
- Install VirtualBox from https://www.virtualbox.org/
- Install the extension pack from https://download.virtualbox.org/virtualbox/6.1.16/Oracle_VM_VirtualBox_Extension_Pack-6.1.16.vbox-extpack
- Download the ISO install CD for Ubuntu 20.04 (or whatever you like) https://ubuntu.com/
- Install Ubuntu in a new VirtualBox virtual machine Steps are not provided here, but here is a google link ;p https://linuxhint.com/install_ubuntu_virtualbox_2004/
If you are running Linux already, or just set it up in a VirtualBox virtual machine, then work through the following steps to install the software you will use while working on this project;
sudo apt install curl
sudo apt install sqlite3
sudo apt-get install python3-pip
sudo apt install pipenv
At this point, use VSCode to clone the repository, then cd into the project's folder and tell pipenv to install all the required dependencies specified in the Pipfile.lock file;
pipenv sync
While you might still run the whole stuff from within VSCode, you are now able to also
pipenv shell
flask DB-reboot
flask run
If you came to this section after installing Windows Subsystem for Linux, you might skip the following and install them instead directly on windows;
snap install postman
sudo snap install dbeaver-ce
sudo snap install --classic code # or code-insiders
Download and run the python 3.8 installer from https://www.python.org/. Tried installing 3.9 instead but as of the writing of these instructions, it leads pipenv to wonder where 3.8 is and apparently there are issues for it to install it on its own; i.e. missing tools?
During the installation
- Select add python to path just to be done with this
- Allow it to bypass the 260 chars MAX_PATH limit after install
Download & run the Visual Studio Code installer from https://code.visualstudio.com/
During the installation
- Select add to path option
Download & run the git installer from https://git-scm.com/ During the installation
- Used version 2.29.2.2
- Select VSCode as default text editor for git
- Select checkout windows style, commit Unix style
After the installation
git config --global user.name "John Doe"
git config --global user.email [email protected]
Open VSCode, click the Git tool button on the left-most vertical panel, select the github repository for the project: cereal-lab/EvoPIE
Finish python setup by running the following commands in the VSCode terminal that you can open using CMD-`. See details at https://docs.python-guide.org/starting/install3/win/
python -m pip install -U pip
pip install --user pipenv
Then, add the following to the path environment variable C:\Users\USERNAME\AppData\Roaming\Python\Python39\Scripts
Setup flask app from the VSCode terminal
- Install all the packages specified in pipfile.lock
pipenv sync
- Activate the pipenvironment for the app
pipenv shell
- Run a custom flask command defined in utils.py to tear down & rebuild an empty data base
flask DB-reboot
- Run the server on local host
flask run
Point your browser to http://127.0.0.1:5000/
The following resource may also be helpful in getting started with python on VSCode https://code.visualstudio.com/docs/python/python-tutorial
These instructions are based on the following tutorial https://docs.microsoft.com/en-us/windows/wsl/install-win10
Before to start, make sure the virtualization extensions are enabled in your BIOS.
Run the following in a power shell terminal (as admin);
- Enable WSL2 (on win10)
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
- Enable the VM features
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
The install of Linux below failed for me so I had to reboot the system to ensure that WSL2 is installed / seen by the installer below
The next time you restart VSCode it will suggest installing "Remote - WSL"
Check what kind of system you are running
systeminfo | find "System Type"
If the type is ARM64, download the ARM64 package at the following link instead
Then, download the Linux kernel from https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
Install the new windows terminal to run the following. (The powershell did not find the wsl command in the path. Had to run the above in a cmd.exe terminal (as admin) instead.) https://docs.microsoft.com/en-us/windows/terminal/get-started
-
set WSL2 as default WSL wsl --set-default-version 2
-
Download Ubuntu 20.04 (or whatever you like) https://aka.ms/wslstore https://www.microsoft.com/store/apps/9n6svws3rx71
-
Don't forget to launch it once it's downloaded
-
Enter password for default user (also in sudoers)
-
update all packages
sudo apt update
sudo apt upgrade
- If WSL2 is not the default, set the distributions to WSL2
wsl --list --verbose
wsl --set-version <distribution name> <versionNumber>
wsl --set-default-version 2
You should now head over to the first section of this page to see about installing the software you will need to run on the WSL2 you just installed.
To run the app and access it from a browser running on windows:
flask run -host 0.0.0.0
To open the web app from your browser from windows, open a WSL terminal to get its internal IP address;
ip addr
Now you may open a browser at http://www.xxx.yyy.zzz:5000/ with the IP address you just got.
- From a terminal in the EvoPie folder, run
flask shell
- Enter
from evopie import *
to import the DB setup and models