Skip to content

IPP-IDE-01-002: VS Code #39

@labbenchstudios

Description

@labbenchstudios

Description

  • This card contains some basic setup and configuration options if you're using VS Code as the IDE for these exercises.
    • Assumptions:
      • You're already familiar with VS Code and its functionality as an IDE.
      • You've used VS Code for Python (or other language) development.
      • You have VS Code installed.
    • Some notes:
      • In the Configuration Details for VS Code section, this guide covers some of the basic configuration options you may want to consider. Your own needs may require different extensions.

Review the README

  • Please see README.md for further information on, and use of, this content.
  • License for embedded documentation and source codes: IPP-DOC-LIC

Estimated effort may vary greatly

  • The estimated level of effort for this exercise shown in the 'Estimate' section below is a very rough approximation. The actual level of effort may vary greatly depending on your development and test environment, experience with the requisite technologies, and many other factors.

Configuration Details for VS Code

Install and Setup

  • Install the latest VS Code for your platform: https://code.visualstudio.com/download
  • Install your favorite extensions
    • NOTE: Extensions for any IDE can be deeply personal! Those listed below are my own personal choices; that said, Python support is REQUIRED if you're using VS Code and following along with the instructions in this guide.
    • For my own development environment, I'm using the following extensions:

Managing Git Repositories in VS Code

  • You can clone the two repositories (ipp-exercise-components and ipp-exercise-docs) outside of the IDE and simply access those directories from within the IDE, or you can clone the two repositories within the IDE.
    • NOTE: Before committing to your new repository, you'll have to authorize the IDE to access your Git repository - the pop-up windows should make this fairly straight forward to do
    • If you want to clone the two repositories within the IDE, do the following:
      • Launch VS Code
      • Close any folder that automatically opens
      • On the main VS Code page, click Clone Git Repository...
      • Enter the full URL in the pop-up dialog (e.g., https://github.com/programming-in-python/ipp-exercise-components.git)
      • The next pop-up will ask you which directory you want to place the cloned code
        • Select your IPP_HOME path
      • Now click CTRL+SHIFT+G (or click the Git icon on the left)
      • Click the three dots (...) next to CHANGES - this will pop up another window
      • Click Remote -> Remove Remote
      • Once that completes, click Remote -> Add Remote
      • Enter your new repository name
      • Repeat this process for the other repository

Dev Environment Configuration for Python

  • After cloning ipp-exercise-components, navigate to the install directory (referred to as IPP_HOME going forward)
  • Notice the .vscode hidden path - this contains two configuration files for your VS Code environment
    • Review .vscode/launch.json. It will contain a relative reference to the main program: "program": "./ipp/app/TestApp.py". This should not need to be changed.
      • You may choose to edit .vscode/launch.json to suit your specific needs of course.
    • Review .vscode/settings.json. It will contain a reference to your configured virtual environment. The line "python.defaultInterpreterPath": "./venv/bin/python" // change to correct path will need to be updated to point to the path to the virtual environment python executable associated with IPP_HOME.
    • EXAMPLE ONLY: If you're virtual environment for development is /mnt/c/ipp/wsl-venv/bin/python, then that line in settings.json will need to change to the following:
      • "python.defaultInterpreterPath": "/mnt/c/ipp/wsl-venv/bin/python"
      • You may choose to make additional edits to .vscode/settings.json to suit your specific needs of course.
  • After launching VS Code (see below for details), the terminal provided within VS Code should automatically start your virtual environment.
    • IMPORTANT: You may need to still set your PYTHONPATH to point to both IPP_HOME and IPP_HOME/tests. You can check this by typing the following in the command line of the terminal:
      • echo $PYTHONPATH
      • If you get the desired output, you should be good to go. If not, set your PYTHONPATH:
      • export PYTHONPATH:{IPP_HOME}:{IPP_HOME}/tests
        • where {IPP_HOME} is the absolute path of your install path
      • Recall you can also add your export PYTHONPATH={IPP_HOME}:{IPP_HOME}/tests declaration within the activate virtual environment shell script if desired.

Launching VS Code

  • From Windows 11 using a WSL Console:

    • cd to IPP_HOME
    • type: code .
  • From macOS or Linux

    • Launch VS Code
    • Open the folder for IPP_HOME

Estimate

  • This process can vary in duration depending on your own computing environment, Internet download speed, etc.

References

Tests

  • N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Lab Module 01 - Setup

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions