Python Environments

Understanding Python Environment Management

One key advantage of the Altair AI Tools Python Devkit is that developers don't need to worry about Python environments on end-users' machines. The devkit automatically handles environment management for Python Extensions, significantly simplifying deployment and distribution.

When you develop an extension, the devkit captures your development environment's configuration and packages this information with your extension, ensuring that your code runs consistently across different systems regardless of their pre-exisiting Python setup. The user does not even need to have Python installed.

Distribute the environment

The devkit offers two approaches for shipping your environment.

Online Mode (default)

  • Bundles only the environment definition with the extension zip file
  • Packages are downloaded during installation
  • Results in smaller extension file size
  • Requires internet connectivity during installation
  • Best for most standard sceanrios.

When to use: This is the recommended approach for most extensions that use publicly available packages and will be installed in environments with reliable internet access.

Read more: Environment creation via Miniforge (online)

Offline Mode

  • Includes all packages from your active environment in the extension zip file
  • Packages pip dependencies directly in the bundle
  • No internet connection required during installation
  • Results in significantly larger extension file size to support multiple operating systems

When to use: Choose this approach for air-gapped environments, or when internet connectivity is limited to restricted.

Read more: Environment creation via Miniforge (offline)

Note: Choose offline mode when deploying to environments with limited internet access, but be aware that this significantly increases the extension file size.

Configure the environment

When building the extension, the environment definition is captured from the activated conda environment. The environment is captured and stored as an env.yml file with the extension in case of online environment.

You can specify the environment name and the version that will be installed on the end-user's machine in the extension.toml file.

[extension]
environment="sample-environment:1.0.0

The Python Extension Loader provides various settings to control the environments on user's machine.

Next, we will learn about the Python Extension Loader