Skip to content

fix for cust sys packages path #1335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions azure_functions_worker/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import os
import pathlib
import sys

# Capabilities
Expand Down Expand Up @@ -54,6 +52,4 @@
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"
3 changes: 1 addition & 2 deletions azure_functions_worker/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,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
Expand Down
11 changes: 4 additions & 7 deletions python/prodV4/worker.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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}')

Expand All @@ -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
Expand Down