fix for cust sys packages path (#1335)

* fix for cust sys packages path

* simplifying cust pkg path
This commit is contained in:
hallvictoria 2023-11-07 13:36:47 -06:00 коммит произвёл GitHub
Родитель 59093870c2
Коммит 42f67cca2b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 6 добавлений и 14 удалений

Просмотреть файл

@ -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 @@ PYTHON_LANGUAGE_RUNTIME = "python"
RETRY_POLICY = "retry_policy"
# Paths
CUSTOMER_PACKAGES_PATH = os.path.join(pathlib.Path.home(),
pathlib.Path(
"site/wwwroot/.python_packages"))
CUSTOMER_PACKAGES_PATH = "/home/site/wwwroot/.python_packages/lib/site-packages"

Просмотреть файл

@ -295,8 +295,7 @@ class Dispatcher(metaclass=DispatcherMeta):
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

Просмотреть файл

@ -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