Skip to main content

Environment Setup

Check Environment Status

Verify if the Python environment is ready:
import { ExuluPython } from '@exulu/backend';

if (ExuluPython.check()) {
  console.log('Python environment is ready');
} else {
  console.log('Python environment needs setup');
}

Validate Environment

Get detailed validation information:
import { ExuluPython } from '@exulu/backend';

const validation = await ExuluPython.validate();

if (validation.valid) {
  console.log('✓ Environment is valid');
} else {
  console.error('✗ Environment issue:', validation.message);
}

Force Rebuild

Rebuild the Python environment from scratch:
import { ExuluPython } from '@exulu/backend';

const result = await ExuluPython.setup({
  force: true,
  verbose: true
});

Setup Options

The setup() method accepts the following options:
force
boolean
default:"false"
Force reinstall even if environment already exists
verbose
boolean
default:"false"
Show detailed output during setup
timeout
number
default:"600000"
Setup timeout in milliseconds (10 minutes)
packageRoot
string
Package root directory (auto-detected if not provided)

CI/CD Integration

GitHub Actions Example

name: Test

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '22'

      - name: Setup Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.12'

      - name: Install dependencies
        run: npm install
        env:
          # Enable Python setup in CI
          SETUP_PYTHON_IN_CI: 1

      - name: Run tests
        run: npm test

Cache Python Environment

- name: Cache Python venv
  uses: actions/cache@v3
  with:
    path: node_modules/@exulu/backend/ee/python/.venv
    key: ${{ runner.os }}-python-${{ hashFiles('**/requirements.txt') }}

Troubleshooting

Solution: Run the setup manually
import { ExuluPython } from '@exulu/backend';
await ExuluPython.setup();
Solution: Install Python 3.10 or higher
# macOS
brew install python@3.12

# Ubuntu/Debian
sudo apt-get install python3.12
Then rebuild:
await ExuluPython.setup({ force: true });
Solution: Increase timeout for long-running scripts
const result = await executePythonScript({
  scriptPath: 'ee/python/my_script.py',
  timeout: 1200000 // 20 minutes
});
Solution: Rebuild the environment
await ExuluPython.setup({ force: true });

Get Setup Instructions

Get helpful instructions for users:
import { ExuluPython } from '@exulu/backend';

const instructions = ExuluPython.instructions();
console.log(instructions);