Skip to content

Commit 9688876

Browse files
authored
Merge pull request #113 from jepler/fix-dependencies-bundlefly
Fix generation of dependencies[] array
2 parents 152702f + 90a2341 commit 9688876

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

circuitpython_build_tools/scripts/build_bundles.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ def build_bundle_json(libs, bundle_version, output_filename, package_folder_pref
117117
"""
118118
Generate a JSON file of all the libraries in libs
119119
"""
120-
packages = []
120+
packages = {}
121+
# TODO simplify this 2-step process
122+
# It mostly exists so that get_bundle_requirements has a way to look up
123+
# "pypi name to bundle name" via `package_list[pypi_name]["module_name"]`
124+
# otherwise it's just shuffling info around
121125
for library_path in libs:
122126
package = {}
123127
package_info = build.get_package_info(library_path, package_folder_prefix)
@@ -130,10 +134,10 @@ def build_bundle_json(libs, bundle_version, output_filename, package_folder_pref
130134
package["version"] = package_info["version"]
131135
package["path"] = "lib/" + package_info["module_name"]
132136
package["library_path"] = library_path
133-
packages.append(package)
137+
packages[module_name] = package
134138

135139
library_submodules = {}
136-
for package in packages:
140+
for package in packages.values():
137141
library = {}
138142
library["package"] = package["is_folder"]
139143
library["pypi_name"] = package["pypi_name"]
@@ -231,15 +235,17 @@ def _find_libraries(current_path, depth):
231235
subdirectories.extend(_find_libraries(path, depth - 1))
232236
return subdirectories
233237

238+
all_modules = ["py", "mpy", "example", "json"]
234239
@click.command()
235240
@click.option('--filename_prefix', required=True, help="Filename prefix for the output zip files.")
236241
@click.option('--output_directory', default="bundles", help="Output location for the zip files.")
237242
@click.option('--library_location', required=True, help="Location of libraries to bundle.")
238243
@click.option('--library_depth', default=0, help="Depth of library folders. This is useful when multiple libraries are bundled together but are initially in separate subfolders.")
239244
@click.option('--package_folder_prefix', default="adafruit_", help="Prefix string used to determine package folders to bundle.")
240245
@click.option('--remote_name', default="origin", help="Git remote name to use during building")
241-
@click.option('--ignore', "-i", multiple=True, type=click.Choice(["py", "mpy", "example", "json"]), help="Bundles to ignore building")
242-
def build_bundles(filename_prefix, output_directory, library_location, library_depth, package_folder_prefix, remote_name, ignore):
246+
@click.option('--ignore', "-i", multiple=True, type=click.Choice(all_modules), help="Bundles to ignore building")
247+
@click.option('--only', "-o", multiple=True, type=click.Choice(all_modules), help="Bundles to build building")
248+
def build_bundles(filename_prefix, output_directory, library_location, library_depth, package_folder_prefix, remote_name, ignore, only):
243249
os.makedirs(output_directory, exist_ok=True)
244250

245251
package_folder_prefix = package_folder_prefix.split(", ")
@@ -259,6 +265,11 @@ def build_bundles(filename_prefix, output_directory, library_location, library_d
259265
with open(build_tools_fn, "w") as f:
260266
f.write(build_tools_version)
261267

268+
if ignore and only:
269+
raise SystemExit("Only specify one of --ignore / --only")
270+
if only:
271+
ignore = set(all_modules) - set(only)
272+
262273
# Build raw source .py bundle
263274
if "py" not in ignore:
264275
zip_filename = os.path.join(output_directory,

0 commit comments

Comments
 (0)