Skip to content

Commit 2e5b348

Browse files
committed
very explicit
1 parent 63c52d8 commit 2e5b348

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

workers/proxy_worker/utils/dependency.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,15 @@ def _get_cx_deps_path() -> str:
225225
if prefix and p.startswith(prefix) and ('site-packages' in p)
226226
]
227227
# Return first or default to first site-packages path in sys.path
228-
default_path = next((p for p in sys.path if 'site-packages' in p), '')
229-
logger.debug("Customer dependencies path candidates: %s. Default: %s", cx_paths, default_path)
230228
if cx_paths:
231229
return cx_paths[0]
230+
elif [''][0]:
231+
return [''][0]
232232
else:
233-
logger.info("No customer dependencies path found, using default: %s", default_path)
234-
return [default_path][0]
233+
default_path = next((p for p in sys.path if 'site-packages' in p), '')
234+
logger.info("No customer dependencies path found, using default: %s",
235+
default_path)
236+
return default_path
235237

236238
@staticmethod
237239
def _get_cx_working_dir() -> str:

workers/tests/unittest_proxy/test_dependency.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_get_cx_deps_path_with_matching_prefix(mock_logger):
7070
"/home/site/wwwroot"
7171
]):
7272
result = DependencyManager._get_cx_deps_path()
73-
73+
7474
assert result == "/home/site/wwwroot/.python_packages/lib/site-packages"
7575
mock_logger.info.assert_any_call(
7676
"Customer dependencies path candidates: %s. Default: %s",
@@ -89,7 +89,7 @@ def test_get_cx_deps_path_no_matching_prefix_returns_default(mock_logger):
8989
"/home/site/wwwroot"
9090
]):
9191
result = DependencyManager._get_cx_deps_path()
92-
92+
9393
assert result == "/usr/local/lib/python3.11/site-packages"
9494
mock_logger.info.assert_any_call(
9595
"Customer dependencies path candidates: %s. Default: %s",
@@ -111,7 +111,7 @@ def test_get_cx_deps_path_no_prefix_env_returns_default(mock_logger):
111111
"/some/other/path"
112112
]):
113113
result = DependencyManager._get_cx_deps_path()
114-
114+
115115
assert result == "/usr/local/lib/python3.11/site-packages"
116116
mock_logger.info.assert_any_call(
117117
"Customer dependencies path candidates: %s. Default: %s",
@@ -133,7 +133,7 @@ def test_get_cx_deps_path_no_site_packages_returns_empty(mock_logger):
133133
"/some/other/path"
134134
]):
135135
result = DependencyManager._get_cx_deps_path()
136-
136+
137137
assert result == ""
138138
mock_logger.info.assert_any_call(
139139
"Customer dependencies path candidates: %s. Default: %s",
@@ -156,7 +156,7 @@ def test_get_cx_deps_path_multiple_matches_returns_first(mock_logger):
156156
"/usr/local/lib/python3.11/site-packages"
157157
]):
158158
result = DependencyManager._get_cx_deps_path()
159-
159+
160160
assert result == "/home/site/wwwroot/.python_packages/lib/site-packages"
161161
# Verify that both paths matching the prefix were found
162162
call_args = mock_logger.info.call_args_list[0]

0 commit comments

Comments
 (0)