The IDC Web Application is currently under development
The system uses Vagrant to setup a consistent, platform independent development environment. To setup your development environment to run locally, you will need to install the following:
- Vagrant
- Oracle VirtualBox
If you are on Windows 8 or above, you will need to make sure you have version 5.0.9 or above to support the network interface. This may involve downloading a test build - PyCharm Pro (Recommended)
From there perform the following steps...
- Once you've installed PyCharm and cloned the repositories, create a directory within the
PycharmProjectsdirectory (the parent directory of your repositories) calledsecure_files/idc. - Copy the
sample.envfile to a file named.envinsecure_files/idc. The setup process requires this name and this path. - Fill out the
.envfile with the proper values
- For most development environments,
MYSQL_ROOT_PASSWORDandDATABASE_PASSWORDcan be the same, andDATABASE_USERcan beroot GCLOUD_PROJECT_ID,OAUTH2_CLIENT_SECRET,OAUTH2_CLIENT_ID, and the application credentials file will be obtained from one of the other developers as part of an initial set of starter files.
PyCharm Pro can be used to run your Web Application as a native Django application.
NOTE: PyCharm 2025 versions no longer include support for remote Python interpreters. Use 2024 or older!
- Go to your PyCharm Settings (On Mac, Go to Preferences;
CMD+,) - Select Project: IDC-Webapp > Project Interpreter
- Click the icon next to the Project Interpreter drop down at the top of the main area
- Click Add Remote
- Select Vagrant (if it asks to start the machine, say yes)
- Set the Python interpreter path to
/home/vagrant/www/shell/python-su.shand click Ok- Be sure you are not using
/user/bin/python3.Xor similar. - The remote interpreter script brings in the PythonPath when launched.
- Be sure you are not using
- Click Ok to save
- Go to Run > Edit Configurations
- If there is not a Django Configuration, add one
- Set the host to
0.0.0.0and the port to8086. - Set the Python Interpreter to the Vagrant Machine (if it is not set to that already)
- Set the working directory to
/home/vagrant/www - Click
...next to theEnvironment variables:, box and add the following values:SECURE_LOCAL_PATH = ../parentDir/secure_files/idc/(you MUST have the trailing/)PYTHONPATH = /home/vagrant/www:/home/vagrant/www/lib:/home/vagrant/www/IDC-CommonVM_PYTHONPATH = /home/vagrant/www:/home/vagrant/www/lib:/home/vagrant/www/IDC-CommonDJANGO_SETTINGS_MODULE = idc.settingsPYTHONUNBUFFERED = 1
- Click ok to save
You will need to set the shell/python-su.sh file to be executable. You can do this via the vagrant machine's command line with the command chmod +x /home/vagrant/www/shell/python-su.sh
(This step is done for you by vagrant-set-env.sh when the VM image is first built.)
To run your server in PyCharm:
- Make sure your Vagrant machine is running by going to Tools > Vagrant > Up
- If this is the first time you've built the VM, it can be time consuming.
- Our VMs are currently running Debian 12 (Bookworm) LTS, which is what the app deploys under as well.
- Once the VM is built, you will need to update the kernel headers and Guest Additions
- Kernel header update:
sudo apt-get -y install dkms build-essential linux-headers-$(uname -r)- NOTE: you may get a 'package not found' error here; if so, you'll need to look up the current header package for this install and use that instead.
- Guest Additions ISO mounting and installation: https://docs.bitnami.com/virtual-machine/faq/configuration/install-virtualbox-guest-additions/
- NOTE: in newer versions of VirtualBox the CD/DVD drives are added under Basic>Storage
- Next, set the
shell/python-su.shscript to executable in the vagrant machine's command line with the commandchmod +x /home/vagrant/www/shell/python-su.sh - You can now click on the Run or Debug icons in the toolbar (upper-right corner of the PyCharm GUI)
- Your server will start and the PyCharm console should show all the logs and output from the system.
- If you are running in debug, you can also use breakpoints to stop the execution and examine variables and code as it runs.
To add Python Libraries or Dependencies, you should add them to the requirements.txt file and they will automatically be pulled down when a new developer starts the system.
- Double-check any new libraries to make sure they don't introduce conflicts.
- Note that sometimes a library will function fine on a local build but fail on the deployment, so always test on the mvm deployment as soon as your PR has been merged into master.
To update your existing python dependencies because of a change, or to pull down additional libraries you need, SSH into the virtual machine and run pip3 install. Through PyCharm, you can take the following steps:
- Click Tools > Start SSH session...
- Select the Vagrant VM Connection you set up
- Type
cd www; sudo pip install -r requirements.txt --upgrade -t lib/
Or from the command line, you can do this by doing the following:
- Open a terminal in the project directory
- Type
vagrant sshto login to the virtual machine - Change directory to the
wwwdirectory (/home/vagrant/www/is the full path) - Run
pip install -r requirements.txt --upgrade -t lib/