X Tutup
Skip to content

Add function support for py-files dependency management#77

Draft
sarasavilli-sf wants to merge 3 commits intomainfrom
sarasavilli/func_pyfile_lib_support
Draft

Add function support for py-files dependency management#77
sarasavilli-sf wants to merge 3 commits intomainfrom
sarasavilli/func_pyfile_lib_support

Conversation

@sarasavilli-sf
Copy link
Collaborator

Summary

This PR implements py-files based dependency management for function package type:

  • Modifies build_native_dependencies.sh to install dependencies directly to py-files directory using pip install --target
  • Adds validation to detect missing py-files directory (indicates build failure)
  • Updates prepare_dependency_archive() to handle both script (tar.gz) and function (py-files) package types
  • Refactors package type detection to CLI layer for cleaner separation of concerns

Changes

Core Implementation

  • build_native_dependencies.sh: Changed from venv-pack to direct pip install to py-files directory
  • deploy.py:
    • Updated prepare_dependency_archive() to accept package_type parameter
    • Added logic to handle function type (copy py-files) vs script type (copy tar.gz)
    • Added validation to detect missing py-files directory
    • Refactored zip() to accept package_type as parameter

Refactoring

  • Moved package type detection from zip() function to CLI layer
  • Updated cli.py commands to detect and pass package_type
  • Removed _get_package_type_for_directory() helper (no longer needed)

Tests

  • Added tests for function package type dependency handling
  • Added tests for missing py-files error case
  • Updated all existing tests to pass package_type parameter
  • Removed obsolete test class for removed helper function

Test Plan

  • Updated existing tests to pass package_type parameter
  • Added tests for function package type dependency handling
  • Added tests for missing py-files error case
  • All tests passing (66 tests in test_deploy.py)
  • Manual testing with sample function projects

Commits

  • Function Support for pyfiles
  • Complete function pyfiles support with pip install and error handling
  • Code refactor


logger.info(f"Dependencies archived to {DEPENDENCIES_ARCHIVE_PATH}")
if package_type == "function":
source_py_files = os.path.join(temp_dir, "py-files")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why make this mandatory?

DEPENDENCIES_ARCHIVE_PATH = os.path.join(
"payload", "archives", DEPENDENCIES_ARCHIVE_FULL_NAME
)
PY_FILES_PATH = os.path.join("payload", "py-files")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need support for libs folder as well? Will you raise a separate PR for the same.

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

X Tutup