Python update agent

The most reliable and effective way to automatically update the Contrast Python agent is to use the Python pip package installer to install and download the latest version available. Because pip manages all dependencies for your Python application, it should already be available and part of your build environment. How frequently you update the Contrast Python agent and where you get updates depends on your organization’s preferences and your Contrast implementation: hosted or on-premises.

The main steps are:

  1. Choose a source for the Contrast Python agent.

  2. Install the agent.

  3. Use scripts for automatic updates.

Before you begin

  • Access to the PyPI repository for the Contrast agent.

  • Confirmed that your Python application runs properly without the Contrast Python agent.

  • Previously successfully installed the Contrast Python agent.

  • Defined a policy for how and when to update the agent, based on your change management policy and the environment where you deploy agents.

Install the agent and use scripts for automatic updates

  1. Choose a source for the Python agent:

    • PyPI public (or private) repository

  2. Specify the Contrast Python agent as a dependency in requirements.txt.

    requirements.txt is the file where you specify which dependencies you want to automatically resolve every time your Python application builds with artifacts from PyPI (public or private). Include the Contrast Python agent here to easily keep every new build of your application aligned with the latest version of the agent. Do not specify a version for contrast-agent, and it will retrieve the latest version.

  3. After you update requirements.txt, use the following command when you build your application. This will automatically download and add or update the Contrast Python agent from PyPI to the Python application:

    $ pip install -U -r requirements.txt

Install and update manually

For some organizations, the requirements.txt file must be consistent across environments, or they do not plan to install the Contrast Python agent into all environments. In these cases, install the agent manually. You can manually update agents as part of a Python build process.

  1. Choose a source for the Python agent:

    • PyPI public (or private) repository

  2. Use the following command to manually retrieve and add or update the Contrast Python agent from PyPI (public or private) to the Python application:

    $ pip install -U contrast-agent

See also