From ba558d810be1b0e56240d7a969ca686ab815f809 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 12 May 2025 15:41:31 -0400 Subject: [PATCH] Enhance dependency management: add 'github' to critical dependencies in app.py and lambda_setup.py, ensuring proper installation and verification during Lambda setup --- app.py | 2 +- scripts/lambda_setup.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index efaced9..cdfd70b 100644 --- a/app.py +++ b/app.py @@ -25,7 +25,7 @@ sys.path.insert(0, path) # Fallback check for critical dependencies -for module in ['pydantic', 'jinja2']: +for module in ['pydantic', 'jinja2', 'github']: try: importlib.import_module(module) except ImportError: diff --git a/scripts/lambda_setup.py b/scripts/lambda_setup.py index a54d601..f6d87d2 100644 --- a/scripts/lambda_setup.py +++ b/scripts/lambda_setup.py @@ -45,14 +45,14 @@ def install_dependencies(): # Explicitly install critical dependencies print("=== Explicitly installing critical dependencies ===") - run_command(f"pip3 install --no-cache-dir pydantic jinja2 -t {LAMBDA_TASK_ROOT}") + run_command(f"pip3 install --no-cache-dir pydantic jinja2 PyGithub -t {LAMBDA_TASK_ROOT}") # Create a .pth file to ensure the Lambda runtime can find the packages with open(f"{LAMBDA_TASK_ROOT}/lambda_path.pth", "w") as f: f.write(f"{LAMBDA_TASK_ROOT}\n") print("=== Installing package in development mode ===") - run_command(f"pip3 install --no-cache-dir -e {TMP_DIR} -t {LAMBDA_TASK_ROOT}") + run_command(f"pip3 install --no-cache-dir -e {TMP_DIR} -t {LAMBDA_TASK_ROOT} -v") def verify_dependencies(): """Verify that key dependencies are installed correctly""" @@ -63,7 +63,7 @@ def verify_dependencies(): run_command("python3 -c 'import sys; print(sys.path)'") # Check key dependencies - dependencies = ['pydantic', 'jinja2'] # Add critical dependencies here + dependencies = ['pydantic', 'jinja2', 'github'] # Add critical dependencies here with open(f"{TMP_DIR}/requirements.txt") as f: for line in f: line = line.strip() @@ -113,7 +113,7 @@ def setup_lambda_environment(): run_command(f"ls -la {LAMBDA_TASK_ROOT}") run_command(f"ls -la {LAMBDA_TASK_ROOT}/template_automation") - # Final check - try to import jinja2 and pydantic from the Lambda environment + # Final check - try to import critical modules from the Lambda environment print("=== Testing key imports from Lambda environment ===") test_import = """ import sys @@ -128,6 +128,11 @@ def setup_lambda_environment(): print("jinja2 successfully imported:", jinja2.__file__) except ImportError as e: print("Error importing jinja2:", str(e)) +try: + import github + print("github successfully imported:", github.__file__) +except ImportError as e: + print("Error importing github:", str(e)) """ with open(f"{LAMBDA_TASK_ROOT}/test_imports.py", "w") as f: f.write(test_import)