Skip to content

Commit 9d05593

Browse files
get9meta-codesync[bot]
authored andcommitted
tee: Automatically install xar dependencies if installing a python xar target
Summary: Running xars requires installing a few fbcode binaries. This wires up automatically installing these dependencies if installing a xar binary, similar to how we install a few python packages for making PARs work. Test Plan: CI Reviewed By: itamaro Differential Revision: D87403958 fbshipit-source-id: 86f622a5c55dec80adf5ec4fa1fd537e721db1af
1 parent 952f5de commit 9d05593

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

antlir/antlir2/bzl/python_helpers.bzl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ PYTHON_OUTPLACE_PAR_ROLLOUT = rollout.create_feature(
2222
def is_python_target(target) -> bool:
2323
return "library-info" in target[DefaultInfo].sub_targets and PythonLibraryInfo in target.sub_target("library-info")
2424

25+
def is_python_xar_target(target) -> bool:
26+
"""
27+
Returns whether the given target is a python xar archive.
28+
"""
29+
info = _extract_python_library_info(target)
30+
if info:
31+
return info.par_style == "xar"
32+
return False
33+
2534
def _extract_python_library_info(target) -> PythonLibraryInfo | None:
2635
"""
2736
Extracts the PythonLibraryInfo from a target.

antlir/antlir2/features/install/install.bzl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ load("@prelude//utils:expect.bzl", "expect")
1010
load("//antlir/antlir2/bzl:binaries_require_repo.bzl", "binaries_require_repo")
1111
load("//antlir/antlir2/bzl:build_phase.bzl", "BuildPhase")
1212
load("//antlir/antlir2/bzl:debuginfo.bzl", "split_binary_anon")
13-
load("//antlir/antlir2/bzl:python_helpers.bzl", "PYTHON_OUTPLACE_PAR_ROLLOUT", "extract_par_elfs", "is_python_target")
13+
load("//antlir/antlir2/bzl:python_helpers.bzl", "PYTHON_OUTPLACE_PAR_ROLLOUT", "extract_par_elfs", "is_python_target", "is_python_xar_target")
1414
load("//antlir/antlir2/bzl:types.bzl", "FeatureInfo", "LayerInfo")
1515
load(
1616
"//antlir/antlir2/features:feature_info.bzl",
@@ -131,6 +131,7 @@ def install(
131131
uses_plugins["_rpm_plugin"] = "antlir//antlir/antlir2/features/rpm:rpm"
132132
exec_deps["_rpm_plan"] = "antlir//antlir/antlir2/features/rpm:plan"
133133
distro_platform_deps["_python_pex_deps"] = "antlir//antlir/distro/toolchain/python:pex-deps"
134+
distro_platform_deps["_python_xar_deps"] = "antlir//antlir/distro/toolchain/python:xar-deps"
134135
distro_platform_deps["_rpm_driver"] = "antlir//antlir/antlir2/features/rpm:driver"
135136
distro_platform_deps["_rpm_resolve"] = "antlir//antlir/antlir2/features/rpm:resolve"
136137
elif transition_to_distro_platform == _transition_to_distro_platform_enum("yes-without-rpm-deps"):
@@ -476,6 +477,8 @@ def _impl(ctx: AnalysisContext) -> list[Provider] | Promise:
476477
rpm_subjects = ctx.actions.declare_output("rpm_requires.txt")
477478
if src_is_python:
478479
features.extend([f.analysis for f in ctx.attrs._python_pex_deps[FeatureInfo].features])
480+
if is_python_xar_target(ctx.attrs.src):
481+
features.extend([f.analysis for f in ctx.attrs._python_xar_deps[FeatureInfo].features])
479482
requires_cmd = cmd_args(
480483
ctx.attrs._rpm_find_requires_py[RunInfo],
481484
rpm_subjects.as_output(),
@@ -557,6 +560,7 @@ install_rule = rule(
557560
"_objcopy": attrs.option(attrs.exec_dep(), default = None),
558561
"_python_outplace_par_override": attrs.bool(default = read_bool("antlir", "python_outplace_par", default = False)),
559562
"_python_pex_deps": attrs.option(attrs.dep(providers = [FeatureInfo]), default = None),
563+
"_python_xar_deps": attrs.option(attrs.dep(providers = [FeatureInfo]), default = None),
560564
"_rpm_driver": attrs.option(attrs.dep(providers = [RunInfo]), default = None),
561565
"_rpm_find_requires": attrs.option(attrs.exec_dep(providers = [RunInfo]), default = None),
562566
"_rpm_find_requires_py": attrs.option(attrs.exec_dep(providers = [RunInfo]), default = None),

0 commit comments

Comments
 (0)