1515
1616from dataclasses import dataclass
1717from pathlib import Path
18- from typing import Sequence , Union
18+ from typing import Union
1919
2020import buck_util
2121import zstd
@@ -46,54 +46,34 @@ def _buck_version_path() -> Path:
4646@dataclass
4747class BuckInfo :
4848 archive_name : str
49- target_versions : Sequence [str ]
5049
5150
52- # Mapping of os family and architecture to buck2 binary versions . The
53- # target version is the hash given by running 'buck2 --version'. The
51+ # Mapping of os family and architecture to buck2 archive name . The target version is the
52+ # hash given by running 'buck2 --version', which is now consistent across platforms . The
5453# archive name is the archive file name to download, as seen under
5554# https://github.com/facebook/buck2/releases/.
5655#
57- # To add or update versions, download the appropriate version of buck2
58- # and run 'buck2 --version'. Add the corresponding entry to the platform
59- # map below, and if adding new os families or architectures, update the
60- # platform detection logic in resolve_buck2().
61- #
62- # Some platforms (linux) provide multiple binaries (GNU and MUSL). All
63- # versions in the list are accepted when validating a user-provided or
64- # system buck2.
56+ # To update Buck2, download the appropriate version of buck2 for your platform, run
57+ # 'buck2 --version', and update BUCK_TARGET_VERSION. To add a new platform, add the
58+ # corresponding entry to the platform map below, and if adding new os families or
59+ # architectures, update the platform detection logic in resolve_buck2().
60+ BUCK_TARGET_VERSION = "2025-05-06-201beb86106fecdc84e30260b0f1abb5bf576988"
61+
6562BUCK_PLATFORM_MAP = {
6663 ("linux" , "x86_64" ): BuckInfo (
6764 archive_name = "buck2-x86_64-unknown-linux-musl.zst" ,
68- target_versions = [
69- # MUSL
70- "edae27cfca00053d9c5f7c7be81b6b0d7d07573a50be374ce53a9d8692afa5fc" ,
71- # GNU
72- "10334cb20cb7c321" ,
73- ],
7465 ),
7566 ("linux" , "aarch64" ): BuckInfo (
7667 archive_name = "buck2-aarch64-unknown-linux-gnu.zst" ,
77- target_versions = [
78- # MUSL
79- "5d7af382acbe0dde70f0e9b0a0bc36deea906077ec1ffe80d3fa280490109051" ,
80- # GNU
81- "08d4382de22fab275978abc7c27c001d7823eb2f" ,
82- ],
8368 ),
8469 ("darwin" , "aarch64" ): BuckInfo (
8570 archive_name = "buck2-aarch64-apple-darwin.zst" ,
86- target_versions = ["f3b7a37732803ed090cd8a37f00cc000" ],
8771 ),
8872 ("darwin" , "x86_64" ): BuckInfo (
8973 archive_name = "buck2-x86_64-apple-darwin.zst" ,
90- target_versions = ["9c9a583658d43e82b41f3fc9d369a9b0" ],
9174 ),
9275 ("windows" , "x86_64" ): BuckInfo (
9376 archive_name = "buck2-x86_64-pc-windows-msvc.exe.zst" ,
94- target_versions = [
95- "c7d378f3f307e9590f0b29a5f7f1b21b8e784f4e4bd30a0160b2a69df50d2ee0"
96- ],
9777 ),
9878}
9979
@@ -160,13 +140,13 @@ def resolve_buck2(args: argparse.Namespace) -> Union[str, int]:
160140 # If we have an explicit buck2 arg, check the version and fail if
161141 # there is a mismatch.
162142 ver = buck_util .get_buck2_version (args .buck2 )
163- if ver in buck_info . target_versions :
143+ if ver == BUCK_TARGET_VERSION :
164144 return args .buck2
165145 else :
166146 print (
167147 f'The provided buck2 binary "{ args .buck2 } " reports version '
168148 f'"{ ver } ", but ExecuTorch needs version '
169- f'"{ buck_info . target_versions [ 0 ] } ". Ensure that the correct buck2'
149+ f'"{ BUCK_TARGET_VERSION } ". Ensure that the correct buck2'
170150 " version is installed or avoid explicitly passing the BUCK2 "
171151 "version to automatically download the correct version." ,
172152 file = sys .stderr ,
@@ -181,7 +161,7 @@ def resolve_buck2(args: argparse.Namespace) -> Union[str, int]:
181161 # Look for system buck2 and check version. Note that this can return
182162 # None.
183163 ver = buck_util .get_buck2_version ("buck2" )
184- if ver in buck_info . target_versions :
164+ if ver == BUCK_TARGET_VERSION :
185165 # Use system buck2.
186166 return "buck2"
187167 else :
@@ -190,9 +170,7 @@ def resolve_buck2(args: argparse.Namespace) -> Union[str, int]:
190170 os .makedirs (cache_dir , exist_ok = True )
191171
192172 buck2_local_path = (
193- (cache_dir / f"buck2-{ buck_info .target_versions [0 ]} " )
194- .absolute ()
195- .as_posix ()
173+ (cache_dir / f"buck2-{ BUCK_TARGET_VERSION } " ).absolute ().as_posix ()
196174 )
197175
198176 # Check for a previously cached buck2 binary. The filename includes
0 commit comments