Unverified Commit 96a6dcda authored by Anant Sharma's avatar Anant Sharma Committed by GitHub
Browse files

build: scan source dir for components in hatch build (#3348)


Signed-off-by: default avatarAnant Sharma <anants@nvidia.com>
parent b51b6e57
...@@ -6,16 +6,29 @@ import subprocess ...@@ -6,16 +6,29 @@ import subprocess
from hatchling.builders.hooks.plugin.interface import BuildHookInterface from hatchling.builders.hooks.plugin.interface import BuildHookInterface
COMPONENTS = [
"common", def get_components():
"frontend", """
"vllm", Scan the components/src/dynamo directory to get the list of available components.
"sglang", Returns full paths to component directories and RuntimeError if no components are found.
"trtllm", """
"mocker", components_dir = os.path.join(
"llama_cpp", os.path.dirname(__file__), "components", "src", "dynamo"
"planner", )
]
if not os.path.exists(components_dir):
raise RuntimeError(f"Components directory not found: {components_dir}")
components = []
for item in os.listdir(components_dir):
item_path = os.path.join(components_dir, item)
if os.path.isdir(item_path) and not item.startswith("."):
components.append(item_path)
if not components:
raise RuntimeError(f"No components found in directory: {components_dir}")
return components
class VersionWriterHook(BuildHookInterface): class VersionWriterHook(BuildHookInterface):
...@@ -45,9 +58,7 @@ class VersionWriterHook(BuildHookInterface): ...@@ -45,9 +58,7 @@ class VersionWriterHook(BuildHookInterface):
version_content = f'# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n# SPDX-License-Identifier: Apache-2.0\n\n# This file is auto-generated at build time\n__version__ = "{full_version}"\n' version_content = f'# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.\n# SPDX-License-Identifier: Apache-2.0\n\n# This file is auto-generated at build time\n__version__ = "{full_version}"\n'
for component in COMPONENTS: for component in get_components():
version_file_path = os.path.join( version_file_path = os.path.join(component, "_version.py")
self.root, f"components/src/dynamo/{component}/_version.py"
)
with open(version_file_path, "w") as f: with open(version_file_path, "w") as f:
f.write(version_content) f.write(version_content)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment