This document covers how to setup a Python environment to work on Agent-based Integrations, including installing the interpreter and ensuring all of the required dependencies are present.
Integrations run only within the Agent’s embedded Python environment, or within the testing environment, the current version of which is recorded in the Omnibus code. The Agent and testing environments are Python2, but an eventual upgrade to Python3 is inevitable, thus new Integrations must be compatible with both versions.
Many operating systems come with Python pre-installed. If your system Python is too old, or if it is not pre-installed, follow the instructions for your OS below.
Any recent version of macOS comes with Python pre-installed; however, it might be older than the version used in the Agent, and might also lack required tools and dependencies. We recommend installing a fresh, dedicated Python interpreter that you can manage without the App Store, following either of the methods listed in this paragraph.
Homebrew is a package manager for macOS that makes a lot easier installing software on macOS, specially from the command line. Follow the “Doing it Right” instructions in the Hitchhiker’s Guide to Python.
Miniconda is the lightweight version of
Anaconda, a Python distribution specifically designed for data processing and scientific computing. Miniconda maintains the Conda package manager, and provides a fully-fledged Python environment along with development libraries and a tool for managing virtual environments - all without cargo loading any library or package normally present in Anaconda.
Download Miniconda and install it following the Conda installation instructions. Miniconda is extremely self contained:
rm -r uninstalls it completely. This is a good option if you don’t want or need a complete Python environment installed system wide, or if you just want to give Python a spin.
Each integration has its own set of dependencies that must be added to Python in order to run the tests, or just to try out the collection code. To avoid polluting your Python installation with libraries and packages that would only be used by an Integration, use a “virtual environment”. A virtual environment is a self contained directory tree that contains an isolated Python installation. When a virtual environment is active, any package you install goes into that directory without affecting the system wide Python installation.
We recommend using Virtualenv to manage Python virtual environments, and virtualenvwrapper to make the process smoother. There’s a comprehensive guide in the Hitchhiker’s Guide to Python describing how to set up these two tools.
If you’re using Miniconda, a tool to manage virtual environments is already there. Please refer to the official guide to learn how to use it.