Managing Your Custom Synapse Python Project (w/ VS Code Examples)
This article will help you with setting up a Python project within VS Code editor.
Requirements
Before we start we need to make sure to have the following installed on our machine:
- Latest version of Python 3,
- VS Code editor and
- the official Python plugin.
Setting Up Your Environment in the Terminal
First we need to create a new project folder and open the integrated terminal, by right clicking on the folder and selecting "Open in Integrated Terminal" option. This will open a new terminal tab inside the VS Code that is pointing to our project folder.
In the terminal we need to execute the following two commands:
- Creating a new Python project:
python3 -m venv .
- Activating a Python Virtual Environment:
source bin/activate
Once we have a virtual environment activated we'll see that our terminal has added our project's name inside brackets of each line.
Before installing the Syncari SDK package we need to make sure that our Python virtual environment is using the project interpreter and not the system one. We can access the command palette by pressing UP + CMD + P (macOS)
or UP + CTRL
+ P (Windows)
, or from menu View
-> Command Palette...
-> Python:Select interpreter
.
Inside the field "Enter path to a Python interpreter" we need to add the following:
./Our_Folder_Name/bin/python
Installing the Syncari SDK
Once we have the interpreter configured (and have the virtual environment active) we can run the pip command from the terminal to install the Syncari SDK Python package:
pip install syncari-sdk
Managing Dependencies
Unless told otherwise, always use version ≥1.3.8 of the Syncari SDK or you may see errors when attempting to use theSyncariRestClient. The latest version of the Syncari SDK can be found HERE.
The requirements.txt
file is where you list your third-party dependencies that you'll want to leverage in your Custom Synapse. This is also where you'll specify what version of the Syncari SDK you want to use.
Below is an example of a typical requirements.txt
file: