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.
Standard dependency management
Section titled “Standard dependency management”How it works
Section titled “How it works”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.
Web IDE deployment
Section titled “Web IDE deployment”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.
CLI and local development
Section titled “CLI and local development”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.
Advanced dependency methods
Section titled “Advanced dependency methods”Relative imports for code sharing
Section titled “Relative imports for code sharing”Scripts can import from other scripts using relative imports:
def foo(): print('Common logic!')
# u/user/custom_scriptfrom u.user.common_logic import fooPinning dependencies
Section titled “Pinning dependencies”Requirements format:
#requirements:#dependency1[optional_module]#dependency2>=0.40Extra requirements:
#extra_requirements:#dependency==0.4import pandasPin and repin syntax:
import dependency # pin: dependency==0.4import nested.modules # pin: nested-modulesPEP-723 inline script metadata
Section titled “PEP-723 inline script metadata”Orvanta supports the standardized PEP-723 format for dependency specification:
# /// script# requires-python = ">=3.12"# dependencies = [# "requests",# "pandas>=1.0"# ]# ///import requestsA shortcut syntax is also available:
#py: >=3.12Private PyPI repositories
Section titled “Private PyPI repositories”Environment variables customize package index settings:
PY_TRUSTED_HOST: Whitelist PyPI hostsPY_INDEX_CERT: Path to custom certificatePY_NATIVE_CERT: Use system certificates
Configuration occurs in Instance settings under registries (Enterprise Edition).
Python runtime settings
Section titled “Python runtime settings”Worker groups support Python-specific settings including additional Python paths and local PIP dependencies via the worker group configuration interface.
Global site-packages
Section titled “Global site-packages”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.
Python version selection
Section titled “Python version selection”Scripts can specify Python versions using annotations like py310, py311, py312, or py313.
Related features
Section titled “Related features”- 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