Skip to main content
Glama
query.bxl3.16 kB
# Copyright (c) Meta Platforms, Inc. and affiliates. # # This source code is licensed under both the MIT license found in the # LICENSE-MIT file in the root directory of this source tree and the Apache # License, Version 2.0 found in the LICENSE-APACHE file in the root directory # of this source tree. load("@prelude//python:python.bzl", "PythonLibraryManifestsTSet") load("@prelude//python:source_db.bzl", "PythonSourceDBInfo") load("@prelude//python/sourcedb:filter.bxl", "filter_root_targets") def _get_python_library_manifests_from_analysis_result( analysis_result: bxl.AnalysisResult) -> [PythonLibraryManifestsTSet, None]: sub_target = analysis_result.providers()[DefaultInfo].sub_targets.get("source-db-no-deps") if sub_target == None: return None python_source_db_info = sub_target.get(PythonSourceDBInfo) if python_source_db_info == None: return None return python_source_db_info.manifests def _get_python_library_manifests_from_targets( ctx: bxl.Context, targets: bxl.UnconfiguredTargetSet) -> list[PythonLibraryManifestsTSet]: return filter(None, [ _get_python_library_manifests_from_analysis_result(analysis_result) for analysis_result in ctx.analysis(targets).values() ]) def get_python_library_manifests_tset_from_targets( ctx: bxl.Context, actions: AnalysisActions, root_targets: bxl.UnconfiguredTargetSet) -> PythonLibraryManifestsTSet: return actions.tset( PythonLibraryManifestsTSet, children = _get_python_library_manifests_from_targets(ctx, root_targets), ) def get_python_library_manifests_tset_from_target_patterns( ctx: bxl.Context, query: bxl.UqueryContext, actions: AnalysisActions, target_patterns: typing.Any) -> PythonLibraryManifestsTSet: root_targets = filter_root_targets(query, target_patterns) return get_python_library_manifests_tset_from_targets(ctx, actions, root_targets) def do_query( ctx: bxl.Context, query: bxl.UqueryContext, actions: AnalysisActions, target_patterns: typing.Any) -> list[ConfiguredTargetLabel]: manifests_of_transitive_dependencies = ( get_python_library_manifests_tset_from_target_patterns( ctx, query, actions, target_patterns, ) ) return [ manifest.label.configured_target() for manifest in manifests_of_transitive_dependencies.traverse() if manifest.src_types != None ] def _do_query_entry_point(ctx: bxl.Context) -> None: query = ctx.uquery() actions = ctx.bxl_actions().actions targets = do_query( ctx, query, actions, [query.eval(target) for target in ctx.cli_args.target], ) ctx.output.print_json([target.raw_target() for target in targets]) query = bxl_main( doc = ( "Expand target patterns and look for all targets in their transitive" + "dependencies that will be built by Pyre." ), impl = _do_query_entry_point, cli_args = { "target": cli_args.list(cli_args.string()), }, )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/systeminit/si'

If you have feedback or need assistance with the MCP directory API, please join our Discord server