Skip to content

VS Code Setup for Plant‐Tracer webapp developers

Steve Barber edited this page Oct 17, 2024 · 10 revisions
  • Make sure you have previously installed git on your machine, and that you have selected a folder in which to clone repositories. One suggestion for MacOS and Linux users: ${HOME}/git
  • Setup VS Code for your OS platform
  • For some reason, the key bindings for line editing in zsh in the VSCode Integrated Terminal don't get set up as they do, for example, in a MacOS Terminal shell. So, strongly consider adding something like 'bindkey -e' to your ~/.zshprofile so that you can comfortably line edit while in VSCode Terminal.
  • Setup to work with Python 3 in VS Code following the instructions here noting the following specifics:
    • Install Python 3. Check in workflows/continuous-integration-pip.yml jobs:build:strategy:matrix:python-version of the branch you are working in for the version you will need
    • Install the VS Code Python extension
    • Using the VS Code Python: Create Environment... command, create a virtual environment for your Python interpreter, and for dependencies, select the appropriate versions of requirements.txt and lib/ctools/requirements.txt for your OS platform and pip3 install these packages into your virtual environment.
  • Clone and open this repository in VS Code:
    • If you have already cloned the webapp repository locally, then File > Open Folder to your local repository's folder.
    • If you want to use the VS Code Git extension to start working with the code, then clone this repository with VS Code.
  • Environment variable initialization: webapp can rely on a some environment variables being set in order to run. To set these for VS Code:
    • Currently, these variables are:
      • PLANTTRACER_CREDENTIALS: overrides the default etc/credentials.ini path. Note that etc/credentials.ini is gitignore'd, and it's better practice for developers to keep credentials out of any git repositories entirely to avoid accidentally exposing them on the public internet.
    • VS Code will automatically import environment settings from a file name .env in your workspace folder (which is your top-level repository directory). You may make one if you wish. .env is already .gitignore'd so this shouldn't bother your commits.
  • Pytest: we are using the pytest package for python unit tests. The VS Code Python extension will prompt you to choose between unittest and pytest, so select pytest and specify the tests folder as the test location.
    • Sadly, in order for the VS Code Python Test Explorer to find all installed packages, they may have to be installed in the global Python package repo and not just in your virtual environment.
Clone this wiki locally