Skip to content

Prefer requirements.txt over uv.lock for Python function builds to avoid excess dev dependencies #14044

@183amir

Description

@183amir

Summary

Currently, uv.lock files are preferred for dependency installation in Python functions. However, this can lead to excessive size due to inclusion of development dependencies, which may quickly exceed the 250MB deployment limit for Python functions.

Rationale

  • uv dependency groups: The uv package manager supports dependency groups (see uv docs), meaning uv.lock can include dev dependencies and other extras not required in production. This increases the risk of deploying unnecessary packages.
  • Size constraints: Python functions on many platforms (e.g., serverless environments) have a strict size limit (such as 250MB). Including dev dependencies in the deployed bundle may cause the function to exceed this limit.
  • Maintaining requirements.txt: uv provides mechanisms to keep requirements.txt in sync with the lock file (see uv integration guide), making requirements.txt a reliable source for production installs.

Proposal

  • Change the build logic to prefer requirements.txt over uv.lock when both are present.
  • Use uv.lock only if requirements.txt is missing.
  • Document the rationale in the codebase.

Impact

  • This change will help ensure only production dependencies are deployed with Python functions, reducing the likelihood of exceeding size limits and improving deployment reliability.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions