Skip to content

Commit 975eaa6

Browse files
andy31415andreilitvinrestyled-commits
authored
Remove usage of a separate python.json environment. (project-chip#35802)
* Remove usage of a separate `python.json` environment. We instead now pull the python according to pigweed setup (so that version is maintained and uniform). This moves windows to also use python 3.11 (because 3.9 will not work) and removes the arm64 pull of a python3.9 as that is redundant. * Some debugging * Fix typo * Fix indent * make logging work * Also remove one package that does not seem exactly used * Restyle * More debug * Fix nargs handling * Add comment * Fix comment * Restyled by autopep8 --------- Co-authored-by: Andrei Litvin <andreilitvin@google.com> Co-authored-by: Restyled.io <commits@restyled.io>
1 parent d4944bf commit 975eaa6

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

scripts/setup/bootstrap.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ _bootstrap_or_activate() {
141141
$_CHIP_ROOT/scripts/setup/gen_pigweed_cipd_json.py \
142142
-i $_PIGWEED_CIPD_JSON \
143143
-o $_GENERATED_PIGWEED_CIPD_JSON \
144-
-e darwin:$_PYTHON_CIPD_JSON
144+
-e darwin:$_PYTHON_CIPD_JSON \
145+
-e windows:$_PYTHON_CIPD_JSON
145146

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

scripts/setup/environment.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"cipd_package_files": [
33
"third_party/pigweed/repo/pw_env_setup/py/pw_env_setup/cipd_setup/arm.json",
4-
"scripts/setup/python.json",
54
"scripts/setup/zap.json"
65
],
76
"virtualenv": {

scripts/setup/gen_pigweed_cipd_json.py

+19-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@
1515
# limitations under the License.
1616

1717
import argparse
18+
import itertools
1819
import json
20+
import logging
1921
import platform
2022

21-
_LIST_OF_PACKAGES_TO_EXCLUDE = ['fuchsia/third_party/rust/']
23+
_LIST_OF_PACKAGES_TO_EXCLUDE = {
24+
'fuchsia/third_party/rust/',
25+
'infra/3pp/tools/renode',
26+
}
2227

2328

2429
def include_package(package: dict) -> bool:
@@ -43,12 +48,20 @@ def generate_new_cipd_package_json(input, output, extra):
4348
# Extra is a list of platform:json.
4449
# Filter it for the given platform and append any resulting packages
4550
my_platform = platform.system().lower()
46-
for item in extra:
51+
52+
logging.info("Loading extra packages for %s", my_platform)
53+
54+
# Extra chain because extra is a list of lists like:
55+
# [['darwin:path1'], ['windows:path2']]
56+
for item in itertools.chain.from_iterable(extra):
4757
inject_platform, path = item.split(':', 1)
4858

4959
if inject_platform.lower() != my_platform:
60+
logging.info("Skipping: %s (i.e. %s)", inject_platform.lower(), path)
5061
continue
5162

63+
logging.info("Appending: %s for this platform", path)
64+
5265
with open(path) as ins:
5366
for package in json.load(ins).get('packages'):
5467
new_file_packages.append(package)
@@ -57,6 +70,8 @@ def generate_new_cipd_package_json(input, output, extra):
5770
with open(output, 'w') as f:
5871
json.dump(new_packages, f, indent=2)
5972

73+
logging.debug("PACKAGES:\n%s\n", json.dumps(new_packages, indent=2))
74+
6075

6176
def main():
6277
parser = argparse.ArgumentParser(
@@ -70,10 +85,11 @@ def main():
7085
'--output', '-o', required=True
7186
)
7287
parser.add_argument(
73-
'--extra', '-e', nargs='*', default=[],
88+
'--extra', '-e', nargs='*', action="append", default=[],
7489
help="Inject extra packages for specific platforms. Format is <platform>:<path_to_json>"
7590
)
7691

92+
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO)
7793
generate_new_cipd_package_json(**vars(parser.parse_args()))
7894

7995

scripts/setup/python.json

-9
This file was deleted.

0 commit comments

Comments
 (0)