Use executable objects with gateway services
You can use executable objects with Python services to specify a custom Python interpreter for your Python scripts. This allows different Python services to use different Python versions or configurations.
While this topic focuses on Python services as an example, executable objects also work with Ansible and OpenTofu services.
You can use executable objects to specify custom versions or installations of any supported tool.
When to use executable objects with Python services
Use executable objects with Python services when you need to:
- Run different Python services with different Python versions (for example, Python 2 and Python 3)
- Use a Python interpreter installed in a non-standard location
- Use Python from a
condaenvironment orpyenvinstallation - Apply specific command-line flags to your Python interpreter
Default behavior
If you don’t specify an executable object, Python services use the system default Python interpreter. This maintains backward compatibility with existing Python services.
Prerequisites
- An executable object configured with a Python interpreter path
- A Git repository that contains your Python script
- Operator role permissions
- Repository authentication configured (if using a private repository)
Create a Python service with an executable object
Use the iagctl create service python-script command with the --executable-object parameter to create a Python service that uses a custom interpreter.
Syntax:
Parameters:
<service-name>: A unique name for the Python service--executable-object: The name of the executable object that defines the Python interpreter--repository: The name of the Git repository that contains your Python script--working-dir: The path within the repository where your script is located--filename: The name of the Python script file to execute
Example:
Create a Python service that uses Python 3.11:
Examples for different Python installations
Use Python from a conda environment
Use Python from pyenv
Use a specific Python version for testing
Run a Python service with an executable object
Run Python services the same way you run other services:
IAG uses the executable object configuration to run your Python script with the correct Python interpreter.
Static environments and executable objects
You cannot use static environments and executable objects together in the same Python service. If you configure a Python service with both a static environment and an executable object, IAG returns an error.
Choose one of the following approaches for each Python service:
- Use a static environment for package management with the system Python interpreter
- Use an executable object to specify a custom Python interpreter without static environments