Skip to content

Commit

Permalink
Remove usage of a separate python.json environment. (project-chip#3…
Browse files Browse the repository at this point in the history
…5802)

* 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 <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
3 people authored Sep 27, 2024
1 parent d4944bf commit 975eaa6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
3 changes: 2 additions & 1 deletion scripts/setup/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ _bootstrap_or_activate() {
$_CHIP_ROOT/scripts/setup/gen_pigweed_cipd_json.py \
-i $_PIGWEED_CIPD_JSON \
-o $_GENERATED_PIGWEED_CIPD_JSON \
-e darwin:$_PYTHON_CIPD_JSON
-e darwin:$_PYTHON_CIPD_JSON \
-e windows:$_PYTHON_CIPD_JSON

if test -n "$GITHUB_ACTION"; then
tee <<EOF >"${_PW_ACTUAL_ENVIRONMENT_ROOT}/pip.conf"
Expand Down
1 change: 0 additions & 1 deletion scripts/setup/environment.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"cipd_package_files": [
"third_party/pigweed/repo/pw_env_setup/py/pw_env_setup/cipd_setup/arm.json",
"scripts/setup/python.json",
"scripts/setup/zap.json"
],
"virtualenv": {
Expand Down
22 changes: 19 additions & 3 deletions scripts/setup/gen_pigweed_cipd_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@
# limitations under the License.

import argparse
import itertools
import json
import logging
import platform

_LIST_OF_PACKAGES_TO_EXCLUDE = ['fuchsia/third_party/rust/']
_LIST_OF_PACKAGES_TO_EXCLUDE = {
'fuchsia/third_party/rust/',
'infra/3pp/tools/renode',
}


def include_package(package: dict) -> bool:
Expand All @@ -43,12 +48,20 @@ def generate_new_cipd_package_json(input, output, extra):
# Extra is a list of platform:json.
# Filter it for the given platform and append any resulting packages
my_platform = platform.system().lower()
for item in extra:

logging.info("Loading extra packages for %s", my_platform)

# Extra chain because extra is a list of lists like:
# [['darwin:path1'], ['windows:path2']]
for item in itertools.chain.from_iterable(extra):
inject_platform, path = item.split(':', 1)

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

logging.info("Appending: %s for this platform", path)

with open(path) as ins:
for package in json.load(ins).get('packages'):
new_file_packages.append(package)
Expand All @@ -57,6 +70,8 @@ def generate_new_cipd_package_json(input, output, extra):
with open(output, 'w') as f:
json.dump(new_packages, f, indent=2)

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


def main():
parser = argparse.ArgumentParser(
Expand All @@ -70,10 +85,11 @@ def main():
'--output', '-o', required=True
)
parser.add_argument(
'--extra', '-e', nargs='*', default=[],
'--extra', '-e', nargs='*', action="append", default=[],
help="Inject extra packages for specific platforms. Format is <platform>:<path_to_json>"
)

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


Expand Down
9 changes: 0 additions & 9 deletions scripts/setup/python.json

This file was deleted.

0 comments on commit 975eaa6

Please sign in to comment.