Skip to content

Python Developer Setup

Connor Jakubik edited this page Nov 11, 2024 · 17 revisions
Simulation Development Workflow → Python Developer Setup

Up to date for Platform 0.27.5

Written by Connor Jakubik

Prerequisites:


Python Developer Setup

NOTE: You really cannot skip any steps when going through this, besides the steps marked things like "ONLY IN PLATFORM VERSIONS _" when your version / OS does not apply. You need to read all of the bullet points as you are going through or you will encounter issues that make the process take longer.


Changelog

  • 2024/11/11 Transferred newer setuo instructions from Lunar SAR API docs.
  • 2023/09/14 Initial copy from internal developer documentation.

First, change these OS settings

  1. For Windows:
    1. Enable long path lengths (Run terminal as admin) (https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=powershell#enable-long-paths-in-windows-10-version-1607-and-later)
    2. (Optional) File Explorer
      1. View Hidden Files (https://support.microsoft.com/en-us/windows/view-hidden-files-and-folders-in-windows-97fbc472-c603-9d90-91d0-1166d1d9f4b5)
      2. View File Extensions (https://www.howtogeek.com/205086/beginner-how-to-make-windows-show-file-extensions/)
    3. OneDrive / Backup & Sync with Google Drive
      1. Be very wary of whether these affect the directories you place Platform files in! Many developer projects are VERY MUCH NOT friendly with these file syncing programs, as they have lots of tiny files that get regenerated often, and many huge files that result in a slow sync. It's not useful to have a backup of Platform files or any other GitHub repo, because once you commit and push changes, they're already backed up in GitHub. It's often very difficult or tedious to remove these files from the sync'd data once they've been sync'd.
      2. You might want to disable these services in their entirety.
      3. AppData/Local and AppData/LocalLow are typically not synced by default.

How to set up your development environment

There are several ways to do python development; here is one way that is the typical way we at SimDynamX set it up.

  1. Install Visual Studio Code https://code.visualstudio.com/ and open it
  2. Do Open Folder to C:\Users\YOUR WINDOWS USERNAME\AppData\Local\SimDynamX\STPro\Assets
  3. Open one of the .py files in Repos/, or create one yourself and open it.
  4. If prompted, install the recommended python extensions, and wait for those installs to complete
  5. Set your Python interpreter to the one that was installed during setup
    1. While having a python file open, click the python version number in the bottom right of the screen image
    2. At the top of the screen, click Enter interpreter path... image
    3. Click Find...
    4. Navigate to AppData\Local\SimDynamX\STPro\Versions\(the highest version number in there)\py\Scripts and select python.exe, then Select Interpreter image
    5. Should now be switched to the correct python interpreter image
    6. And you should get syntax highlighting for the spaceteams python module. image

General process for adding or modifying Python behavior in a Space Teams simulation:

  1. Editing Python scripts that use the spaceteams module to interface with either SimConfig / EntityConfig objects or Entities in a running simulation.
  2. Modifying a Sim Config to:
    1. Declare a System Instance of Python type that uses a particular python script as its Source path.
    2. Assign that System Instance's Nametag to the Systems on any Entities it should "see"/affect.
  3. Run that simulation through one of a number of methods.

Further Documentation

Clone this wiki locally