1212import dataclasses
1313import logging
1414from pathlib import Path
15+ import toml
16+
1517
1618# pip-licenses is used to query all python packages for license information
1719PYTHON_LICENSE_COMMAND = "pip-licenses"
@@ -224,6 +226,35 @@ def remove_trailing_blank_lines(notice_file_path: Path):
224226 f .write ("\n " )
225227
226228
229+ def find_uv_lock_file (connector_path : Path ) -> Optional [Path ]:
230+ """
231+ Find uv.lock file in the connector_path or its subdirectories.
232+ Returns the path to the uv.lock file if found, None otherwise.
233+ """
234+ # Check top level directory first
235+ uv_lock_path = connector_path / "uv.lock"
236+ if uv_lock_path .exists ():
237+ logging .info ("Found uv.lock in top level directory: %s" , uv_lock_path )
238+ return uv_lock_path
239+
240+ # Check subdirectories
241+ for uv_lock_path in connector_path .rglob ("uv.lock" ):
242+ logging .info ("Found uv.lock in subdirectory: %s" , uv_lock_path )
243+ return uv_lock_path
244+
245+ return None
246+
247+
248+ def get_sdkfied_app_dependencies (pyproject_toml_path : Path ) -> list [str ]:
249+ """
250+ Get the dependencies from the pyproject.toml file.
251+ """
252+ with open (pyproject_toml_path ) as f :
253+ toml_data = toml .load (f )
254+
255+ return toml_data .get ("project" , {}).get ("dependencies" , [])
256+
257+
227258def main ():
228259 """
229260 Generate a NOTICE file.
@@ -243,7 +274,11 @@ def main():
243274 f .write (f"Splunk SOAR App: { app_name } \n { app_license } \n " )
244275
245276 # Get all python package dependencies
246- packages = get_package_dependencies ()
277+ if uv_lock_path := find_uv_lock_file (connector_path ):
278+ uv_lock_dir = uv_lock_path .parent
279+ packages = get_sdkfied_app_dependencies (uv_lock_dir / "pyproject.toml" )
280+ else :
281+ packages = get_package_dependencies ()
247282 valid_packages = [
248283 package for package in packages if package not in EXCLUDED_PYTHON_PACKAGES
249284 ]
0 commit comments