Skip to content

fix duplicate lib dirs + update actions environment #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 21, 2024
7 changes: 6 additions & 1 deletion .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ on:

jobs:
build-images:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- run: python3 -m venv build_images_venv
- 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
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 34 additions & 1 deletion create_requirement_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,17 @@ def get_dependencies(libraries):
lib_name = libraries_to_check[0]
del libraries_to_check[0]

lib_obj = bundle_data[lib_name]
if lib_name in bundle_data:
lib_obj = bundle_data[lib_name]
else:
# 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]
Expand Down Expand Up @@ -376,6 +386,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 = tuple()
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
Expand Down
Loading