From 646c36c06f30ef263c43075bf375b72da71ce59e Mon Sep 17 00:00:00 2001 From: Victoria Hall Date: Tue, 24 Oct 2023 17:00:38 -0500 Subject: [PATCH 1/2] fix for cust sys packages path --- azure_functions_worker/constants.py | 2 +- azure_functions_worker/dispatcher.py | 3 +-- python/prodV4/worker.py | 11 ++++------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/azure_functions_worker/constants.py b/azure_functions_worker/constants.py index d094fb14b..c617d4155 100644 --- a/azure_functions_worker/constants.py +++ b/azure_functions_worker/constants.py @@ -56,4 +56,4 @@ # Paths CUSTOMER_PACKAGES_PATH = os.path.join(pathlib.Path.home(), pathlib.Path( - "site/wwwroot/.python_packages")) + "site/wwwroot/.python_packages/lib/site-packages")) diff --git a/azure_functions_worker/dispatcher.py b/azure_functions_worker/dispatcher.py index 66f89e219..18347ea8e 100644 --- a/azure_functions_worker/dispatcher.py +++ b/azure_functions_worker/dispatcher.py @@ -298,8 +298,7 @@ async def _handle__worker_init_request(self, request): import azure.functions # NoQA if CUSTOMER_PACKAGES_PATH not in sys.path: - logger.warning("Customer packages not in sys path. " - "This should never happen! ") + logger.warning("Customer packages not in sys path.") # loading bindings registry and saving results to a static # dictionary which will be later used in the invocation request diff --git a/python/prodV4/worker.py b/python/prodV4/worker.py index b3c0faf01..3365b69c3 100644 --- a/python/prodV4/worker.py +++ b/python/prodV4/worker.py @@ -1,10 +1,9 @@ import os +import pathlib import sys -from pathlib import Path - # User packages -PKGS_PATH = "site/wwwroot/.python_packages" +PKGS_PATH = "/home/site/wwwroot/.python_packages" VENV_PKGS_PATH = "site/wwwroot/worker_venv" PKGS = "lib/site-packages" @@ -36,12 +35,10 @@ def determine_user_pkg_paths(): """ minor_version = sys.version_info[1] - home = Path.home() - pkgs_path = os.path.join(home, PKGS_PATH) usr_packages_path = [] if minor_version in (7, 8, 9, 10, 11): - usr_packages_path.append(os.path.join(pkgs_path, PKGS)) + usr_packages_path.append(os.path.join(PKGS_PATH, PKGS)) else: raise RuntimeError(f'Unsupported Python version: 3.{minor_version}') @@ -50,7 +47,7 @@ def determine_user_pkg_paths(): if __name__ == '__main__': # worker.py lives in the same directory as azure_functions_worker - func_worker_dir = str(Path(__file__).absolute().parent) + func_worker_dir = str(pathlib.Path(__file__).absolute().parent) env = os.environ # Setting up python path for all environments to prioritize From 3472e9e61ceec619eeab05a0d2f1d5f61727904e Mon Sep 17 00:00:00 2001 From: hallvictoria Date: Mon, 30 Oct 2023 11:37:07 -0500 Subject: [PATCH 2/2] simplifying cust pkg path --- azure_functions_worker/constants.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/azure_functions_worker/constants.py b/azure_functions_worker/constants.py index c617d4155..523f36364 100644 --- a/azure_functions_worker/constants.py +++ b/azure_functions_worker/constants.py @@ -1,7 +1,5 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -import os -import pathlib import sys # Capabilities @@ -54,6 +52,4 @@ RETRY_POLICY = "retry_policy" # Paths -CUSTOMER_PACKAGES_PATH = os.path.join(pathlib.Path.home(), - pathlib.Path( - "site/wwwroot/.python_packages/lib/site-packages")) +CUSTOMER_PACKAGES_PATH = "/home/site/wwwroot/.python_packages/lib/site-packages"