From 84e484722d602a23eee60f363b9691630961ba6a Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 16 Sep 2024 09:28:44 -0500 Subject: [PATCH 1/8] fix duplicate lib dirs --- create_requirement_images.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/create_requirement_images.py b/create_requirement_images.py index 40d4980..0a3f420 100755 --- a/create_requirement_images.py +++ b/create_requirement_images.py @@ -317,7 +317,17 @@ def get_dependencies(libraries): lib_name = libraries_to_check[0] del libraries_to_check[0] - lib_obj = bundle_data[lib_name] + try: + lib_obj = bundle_data[lib_name] + except KeyError: + # Library isn't in bundle, so we don't know about its + # dependencies. + if "." in lib_name: + file_list.add(lib_name) + else: + package_list.add(lib_name) + continue + for dep_name in lib_obj["dependencies"]: libraries_to_check.append(dep_name) dep_obj = bundle_data[dep_name] @@ -377,6 +387,29 @@ def make_sd_dir(position): triangle_icon=right_triangle, ) + def filter_custom_project_libs(project_file_set): + """ + Find and remove the custom project lib folder. + Returns a tuple with the contents of the custom project lib folder + which will in turn get included in the libraries list that the + tool uses to generate the "main" lib folder in the screenshot. + """ + _custom_libs = None + remove_files = [] + for file in project_file_set: + if not isinstance(file, tuple): + continue + if file[0] == "lib": + _custom_libs = file[1] + remove_files.append(file) + for file in remove_files: + project_file_set.remove(file) + return _custom_libs + + custom_libs = filter_custom_project_libs(project_files) + libs_list = list(libs) + libs_list.extend(custom_libs) + libs = set(libs_list) final_list_to_render = sort_libraries(libs) if settings_required(final_list_to_render): context["added_settings_toml"] = True From 7be5d5292277dfd2bce74913791df10fbc37caa4 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 16 Sep 2024 12:04:08 -0500 Subject: [PATCH 2/8] try newer OS in build-images task container --- .github/workflows/build-images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index cb67b70..ed9e3d3 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -10,7 +10,7 @@ on: jobs: build-images: - runs-on: ubuntu-20.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v2 - run: python3 -mpip install -r requirements.txt From 0c119c2cb00c407bcde1ed9087365e6f9cef0550 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 16 Sep 2024 12:06:18 -0500 Subject: [PATCH 3/8] use venv --- .github/workflows/build-images.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index ed9e3d3..74fe44d 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -13,6 +13,8 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v2 + - run: python3 -m venv build_images_venv + - run: source build_images_venv/bin/activate - run: python3 -mpip install -r requirements.txt - run: git clone --depth=1 https://github.com/adafruit/Adafruit_Learning_System_Guides learn - run: env LEARN_GUIDE_REPO=learn/ python3 create_requirement_images.py From 5804ae99fd351debc6355b5a22a54cfeabc763c0 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 16 Sep 2024 12:09:23 -0500 Subject: [PATCH 4/8] fix venv activate --- .github/workflows/build-images.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 74fe44d..8e5b346 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -14,7 +14,10 @@ jobs: steps: - uses: actions/checkout@v2 - run: python3 -m venv build_images_venv - - run: source build_images_venv/bin/activate + - name: Activate virtualenv + run: | + . .build_images_venv/bin/activate + echo PATH=$PATH >> $GITHUB_ENV - run: python3 -mpip install -r requirements.txt - run: git clone --depth=1 https://github.com/adafruit/Adafruit_Learning_System_Guides learn - run: env LEARN_GUIDE_REPO=learn/ python3 create_requirement_images.py From 7854e8069ef575c640fd5ee7987c4a9550871957 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 16 Sep 2024 12:10:07 -0500 Subject: [PATCH 5/8] fix venv path --- .github/workflows/build-images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 8e5b346..813f89c 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -16,7 +16,7 @@ jobs: - run: python3 -m venv build_images_venv - name: Activate virtualenv run: | - . .build_images_venv/bin/activate + . build_images_venv/bin/activate echo PATH=$PATH >> $GITHUB_ENV - run: python3 -mpip install -r requirements.txt - run: git clone --depth=1 https://github.com/adafruit/Adafruit_Learning_System_Guides learn From a356a51b287d5527504a221ad80e42aa4b51a881 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 16 Sep 2024 12:12:24 -0500 Subject: [PATCH 6/8] add learn command to task --- .github/workflows/build-images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 813f89c..ebfb537 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -20,7 +20,7 @@ jobs: echo PATH=$PATH >> $GITHUB_ENV - run: python3 -mpip install -r requirements.txt - run: git clone --depth=1 https://github.com/adafruit/Adafruit_Learning_System_Guides learn - - run: env LEARN_GUIDE_REPO=learn/ python3 create_requirement_images.py + - run: env LEARN_GUIDE_REPO=learn/ python3 create_requirement_images.py learn - uses: actions/upload-artifact@v4 with: name: images From c365b948484d550b7bac4cb448e9c2aa23075679 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 16 Sep 2024 12:16:25 -0500 Subject: [PATCH 7/8] revert unneeded subcommand. add new jsons to gitignore. return empty tuple instead of None if no custom libs --- .github/workflows/build-images.yml | 2 +- .gitignore | 2 ++ create_requirement_images.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index ebfb537..813f89c 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -20,7 +20,7 @@ jobs: echo PATH=$PATH >> $GITHUB_ENV - run: python3 -mpip install -r requirements.txt - run: git clone --depth=1 https://github.com/adafruit/Adafruit_Learning_System_Guides learn - - run: env LEARN_GUIDE_REPO=learn/ python3 create_requirement_images.py learn + - run: env LEARN_GUIDE_REPO=learn/ python3 create_requirement_images.py - uses: actions/upload-artifact@v4 with: name: images diff --git a/.gitignore b/.gitignore index ad2a4eb..c4c0d82 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ __pycache__ latest_bundle_data.json latest_bundle_tag.json +latest_community_bundle_data.json +latest_community_bundle_tag.json generated_images # Virtual environment-specific files diff --git a/create_requirement_images.py b/create_requirement_images.py index d9d32f7..021a3a4 100755 --- a/create_requirement_images.py +++ b/create_requirement_images.py @@ -393,7 +393,7 @@ def filter_custom_project_libs(project_file_set): which will in turn get included in the libraries list that the tool uses to generate the "main" lib folder in the screenshot. """ - _custom_libs = None + _custom_libs = tuple() remove_files = [] for file in project_file_set: if not isinstance(file, tuple): From a2b36ed1df542cc66e939ebc10e5a46627959c3f Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 16 Sep 2024 12:26:06 -0500 Subject: [PATCH 8/8] use if/else instead of try/except --- create_requirement_images.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/create_requirement_images.py b/create_requirement_images.py index 021a3a4..b9b185a 100755 --- a/create_requirement_images.py +++ b/create_requirement_images.py @@ -316,9 +316,9 @@ def get_dependencies(libraries): lib_name = libraries_to_check[0] del libraries_to_check[0] - try: + if lib_name in bundle_data: lib_obj = bundle_data[lib_name] - except KeyError: + else: # Library isn't in bundle, so we don't know about its # dependencies. if "." in lib_name: