Skip to content

fix: fix default cx deps path for 3.13#1833

Merged
hallvictoria merged 10 commits intodevfrom
hallvictoria/proxy-cx-deps
Mar 10, 2026
Merged

fix: fix default cx deps path for 3.13#1833
hallvictoria merged 10 commits intodevfrom
hallvictoria/proxy-cx-deps

Conversation

@hallvictoria
Copy link
Contributor

@hallvictoria hallvictoria commented Feb 27, 2026

Description

Overview
This PR fixes an issue with customer dependency path resolution in the Python 3.13+ proxy worker. When running locally with an environment outside of the Function App level, the worker was unable to locate customer dependencies, causing import failures.

Problem
Previously, when the customer dependencies path cx_deps_path couldn't be identified, dependency isolation logic would execute incorrectly or cause import errors when trying to load customer packages.

Solution
The PR introduces a fallback mechanism that:

  1. Detects local development environments - Uses is_azure_environment() to determine if running locally
  2. Falls back to site-packages - When no customer path is found AND not in Azure environment, uses the first site-packages directory fromsys.path as the default
  3. Logs the behavior - Adds informational logging when the default path is used

Key Changes

  • Created new method _add_cx_deps_to_sys_path() that handles adding customer dependencies to sys.path with environment-aware fallback logic
  • Logic: If path is empty AND not is_azure_environment(), insert first site-packages path as default
  • In Azure environments, no action is taken

Impact

  • Local development: Developers can now run Azure Functions locally with a virtual environment that is outside of the Function App level, as the worker will intelligently fall back to local site-packages
  • Azure environments: No change in behavior - still respects the configured paths or returns empty for placeholder mode

Fixes #


Pull Request Checklist

Host-Worker Contract

  • Does this PR impact the host-worker contract (e.g., gRPC messages, shared interfaces)?
    • If yes, have the changes been applied to:
      • azure_functions_worker (Python <= 3.12)
      • proxy_worker (Python >= 3.13)
    • If no, please explain why:

Worker Execution Logic

  • Does this PR affect worker execution logic (e.g., function invocation, bindings, lifecycle)?
    If yes, please answer the following:

Python Version Coverage

  • Does this change apply to both Python <=3.12 and 3.13+?
  • If yes, have the changes been made to:
    • azure_functions_worker (Python <= 3.12)
    • runtimes/v1 / runtimes/v2 (Python >= 3.13)
  • If no, please explain why:

Programming Model Compatibility (for Python 3.13+)

  • Does this change apply to both:
    • V1 programming model (runtimes/v1)?
    • V2 programming model (runtimes/v2)?
  • Explanation (if limited to one model):

@hallvictoria hallvictoria marked this pull request as ready for review February 27, 2026 21:41
@hallvictoria hallvictoria merged commit b2f8d87 into dev Mar 10, 2026
45 of 47 checks passed
@hallvictoria hallvictoria deleted the hallvictoria/proxy-cx-deps branch March 10, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants