15
15
16
16
from dataclasses import dataclass
17
17
from pathlib import Path
18
- from typing import Sequence , Union
18
+ from typing import Union
19
19
20
20
import buck_util
21
21
import zstd
@@ -46,54 +46,34 @@ def _buck_version_path() -> Path:
46
46
@dataclass
47
47
class BuckInfo :
48
48
archive_name : str
49
- target_versions : Sequence [str ]
50
49
51
50
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
54
53
# archive name is the archive file name to download, as seen under
55
54
# https://github.com/facebook/buck2/releases/.
56
55
#
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
+
65
62
BUCK_PLATFORM_MAP = {
66
63
("linux" , "x86_64" ): BuckInfo (
67
64
archive_name = "buck2-x86_64-unknown-linux-musl.zst" ,
68
- target_versions = [
69
- # MUSL
70
- "edae27cfca00053d9c5f7c7be81b6b0d7d07573a50be374ce53a9d8692afa5fc" ,
71
- # GNU
72
- "10334cb20cb7c321" ,
73
- ],
74
65
),
75
66
("linux" , "aarch64" ): BuckInfo (
76
67
archive_name = "buck2-aarch64-unknown-linux-gnu.zst" ,
77
- target_versions = [
78
- # MUSL
79
- "5d7af382acbe0dde70f0e9b0a0bc36deea906077ec1ffe80d3fa280490109051" ,
80
- # GNU
81
- "08d4382de22fab275978abc7c27c001d7823eb2f" ,
82
- ],
83
68
),
84
69
("darwin" , "aarch64" ): BuckInfo (
85
70
archive_name = "buck2-aarch64-apple-darwin.zst" ,
86
- target_versions = ["f3b7a37732803ed090cd8a37f00cc000" ],
87
71
),
88
72
("darwin" , "x86_64" ): BuckInfo (
89
73
archive_name = "buck2-x86_64-apple-darwin.zst" ,
90
- target_versions = ["9c9a583658d43e82b41f3fc9d369a9b0" ],
91
74
),
92
75
("windows" , "x86_64" ): BuckInfo (
93
76
archive_name = "buck2-x86_64-pc-windows-msvc.exe.zst" ,
94
- target_versions = [
95
- "c7d378f3f307e9590f0b29a5f7f1b21b8e784f4e4bd30a0160b2a69df50d2ee0"
96
- ],
97
77
),
98
78
}
99
79
@@ -160,13 +140,13 @@ def resolve_buck2(args: argparse.Namespace) -> Union[str, int]:
160
140
# If we have an explicit buck2 arg, check the version and fail if
161
141
# there is a mismatch.
162
142
ver = buck_util .get_buck2_version (args .buck2 )
163
- if ver in buck_info . target_versions :
143
+ if ver == BUCK_TARGET_VERSION :
164
144
return args .buck2
165
145
else :
166
146
print (
167
147
f'The provided buck2 binary "{ args .buck2 } " reports version '
168
148
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'
170
150
" version is installed or avoid explicitly passing the BUCK2 "
171
151
"version to automatically download the correct version." ,
172
152
file = sys .stderr ,
@@ -181,7 +161,7 @@ def resolve_buck2(args: argparse.Namespace) -> Union[str, int]:
181
161
# Look for system buck2 and check version. Note that this can return
182
162
# None.
183
163
ver = buck_util .get_buck2_version ("buck2" )
184
- if ver in buck_info . target_versions :
164
+ if ver == BUCK_TARGET_VERSION :
185
165
# Use system buck2.
186
166
return "buck2"
187
167
else :
@@ -190,9 +170,7 @@ def resolve_buck2(args: argparse.Namespace) -> Union[str, int]:
190
170
os .makedirs (cache_dir , exist_ok = True )
191
171
192
172
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 ()
196
174
)
197
175
198
176
# Check for a previously cached buck2 binary. The filename includes
0 commit comments