Skip to content

Commit 514f80a

Browse files
fix: sdkify pre commit
1 parent 80c6e22 commit 514f80a

File tree

3 files changed

+805
-413
lines changed

3 files changed

+805
-413
lines changed

local_hooks/generate_notice.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import dataclasses
1313
import logging
1414
from pathlib import Path
15+
import toml
16+
1517

1618
# pip-licenses is used to query all python packages for license information
1719
PYTHON_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+
227258
def 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
]

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ dependencies = [
1414
"django<5",
1515
"packaging>=24.2",
1616
"requests>=2.32.3",
17+
"splunk-soar-sdk>=1.6.0",
18+
"tomli>=1.2.0;python_version<'3.11'",
1719
]
1820

1921
[project.scripts]

0 commit comments

Comments
 (0)