Skip to content

Dependencies in Python

Orvanta handles Python dependencies automatically by parsing import statements directly within scripts, eliminating the need for separate dependency files. The platform automatically handles the resolution and caching of script dependencies to ensure fast and consistent execution.

In standard mode, Orvanta analyzes top-level imports when scripts are saved and generates an associated lockfile. This ensures that the same version of a Python script is always executed with the same versions of its dependencies.

The system uses heuristics to map import names to package names, though exceptions exist. Contributors can submit pull requests to add mappings for packages where imports don’t directly match package names.

When deployed through the Web IDE, scripts receive automatically generated lockfiles. Import statements can include version pins, or Orvanta uses the latest available version. Orvanta’s workers cache dependencies to ensure fast performance without the need to pre-package dependencies — most jobs take under 100ms end-to-end.

At each deployment, lockfiles are recomputed from script imports and relative imports.

With the CLI, each script includes three files:

  • Content file (.py)
  • Metadata file (.yaml)
  • Lockfile (.lock)

The orvanta generate-metadata command creates and updates lockfiles by requesting dependency jobs from Orvanta servers.

Scripts can import from other scripts using relative imports:

u/user/common_logic
def foo():
print('Common logic!')
# u/user/custom_script
from u.user.common_logic import foo

Requirements format:

#requirements:
#dependency1[optional_module]
#dependency2>=0.40

Extra requirements:

#extra_requirements:
#dependency==0.4
import pandas

Pin and repin syntax:

import dependency # pin: dependency==0.4
import nested.modules # pin: nested-modules

Orvanta supports the standardized PEP-723 format for dependency specification:

# /// script
# requires-python = ">=3.12"
# dependencies = [
# "requests",
# "pandas>=1.0"
# ]
# ///
import requests

A shortcut syntax is also available:

#py: >=3.12

Environment variables customize package index settings:

  • PY_TRUSTED_HOST: Whitelist PyPI hosts
  • PY_INDEX_CERT: Path to custom certificate
  • PY_NATIVE_CERT: Use system certificates

Configuration occurs in Instance settings under registries (Enterprise Edition).

Worker groups support Python-specific settings including additional Python paths and local PIP dependencies via the worker group configuration interface.

Pre-installed packages in /tmp/orvanta/cache/python_<major>_<minor>/global-site-packages are available system-wide. To prevent resolver conflicts, add package names to the worker group’s PIP local dependencies list or set the PIP_LOCAL_DEPENDENCIES environment variable.

Scripts can specify Python versions using annotations like py310, py311, py312, or py313.

  • Workspace dependencies: Centralized dependency management at workspace level
  • Relative imports: Share common logic across scripts
  • Version pinning: Control exact dependency versions
  • Caching: Worker-level dependency caching for performance