Skip to content

Commit 3e8ec2d

Browse files
committed
Make pigweed pull python 3.11 on macs, to have a consistent build environment
1 parent 08b8a63 commit 3e8ec2d

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

scripts/setup/bootstrap.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,15 @@ _bootstrap_or_activate() {
133133
export PW_DOCTOR_SKIP_CIPD_CHECKS=1
134134
export PATH # https://bugs.chromium.org/p/pigweed/issues/detail?id=281
135135

136-
local _PIGWEED_CIPD_JSON="$_CHIP_ROOT/third_party/pigweed/repo/pw_env_setup/py/pw_env_setup/cipd_setup/pigweed.json"
136+
local _PIGWEED_CIPD_JSON_ROOT="$_CHIP_ROOT/third_party/pigweed/repo/pw_env_setup/py/pw_env_setup/cipd_setup"
137+
local _PIGWEED_CIPD_JSON="$_PIGWEED_CIPD_JSON_ROOT/pigweed.json"
138+
local _PYTHON_CIPD_JSON="$_PIGWEED_CIPD_JSON_ROOT/python311.json"
137139
mkdir -p "$_PW_ACTUAL_ENVIRONMENT_ROOT"
138140
local _GENERATED_PIGWEED_CIPD_JSON="$_PW_ACTUAL_ENVIRONMENT_ROOT/pigweed.json"
139-
$_CHIP_ROOT/scripts/setup/gen_pigweed_cipd_json.py -i $_PIGWEED_CIPD_JSON -o $_GENERATED_PIGWEED_CIPD_JSON
141+
$_CHIP_ROOT/scripts/setup/gen_pigweed_cipd_json.py \
142+
-i $_PIGWEED_CIPD_JSON \
143+
-o $_GENERATED_PIGWEED_CIPD_JSON \
144+
-e darwin:$_PYTHON_CIPD_JSON
140145

141146
if test -n "$GITHUB_ACTION"; then
142147
tee <<EOF >"${_PW_ACTUAL_ENVIRONMENT_ROOT}/pip.conf"

scripts/setup/gen_pigweed_cipd_json.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
import argparse
1818
import json
19+
import platform
20+
from collections import defaultdict
1921

2022
_LIST_OF_PACKAGES_TO_EXCLUDE = ['fuchsia/third_party/rust/']
2123

@@ -32,12 +34,27 @@ def include_package(package: dict) -> bool:
3234
return True
3335

3436

35-
def generate_new_cipd_package_json(input, output):
37+
def generate_new_cipd_package_json(input, output, extra):
3638
with open(input) as ins:
3739
packages = json.load(ins)
40+
3841
file_packages = packages.get('packages')
3942
new_file_packages = [x for x in file_packages if include_package(x)]
4043

44+
# Extra is a list of platform:json.
45+
# Filter it for the given platform and append any resulting packages
46+
my_platform = platform.system().lower()
47+
for item in extra:
48+
inject_platform, path = item.split(':', 1)
49+
50+
if inject_platform.lower() != my_platform:
51+
continue
52+
53+
with open(path) as ins:
54+
for package in json.load(ins).get('packages'):
55+
new_file_packages.append(package)
56+
57+
4158
new_packages = {'packages': new_file_packages}
4259
with open(output, 'w') as f:
4360
json.dump(new_packages, f, indent=2)
@@ -54,6 +71,11 @@ def main():
5471
parser.add_argument(
5572
'--output', '-o', required=True
5673
)
74+
parser.add_argument(
75+
'--extra', '-e', nargs='*', default=[],
76+
help="Inject extra packages for specific platforms. Format is <platform>:<path_to_json>"
77+
)
78+
5779
generate_new_cipd_package_json(**vars(parser.parse_args()))
5880

5981

0 commit comments

Comments
 (0)