Skip to content

Fix Example Bundling When 'examples' In Subfolder Name #46

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 1 commit into from
Aug 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions circuitpython_build_tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,21 @@ def library(library_path, output_directory, package_folder_prefix,
# 'walked_files' while retaining subdirectory structure
walked_files = []
for path in path_walk:
rel_path = ""
if filename.startswith("examples"):
path_tail_idx = path[0].rfind("examples/") + 9
path_tail_idx = path[0].rfind("examples/")
if path_tail_idx != -1:
rel_path = "{}/".format(path[0][path_tail_idx + 9:])

else:
path_tail_idx = (path[0].rfind("{}/".format(filename))
+ (len(filename) +1))
path_tail = path[0][path_tail_idx:]
rel_path = ""
# if this entry is the package top dir, keep it
# empty so we don't double append the dir name
if filename not in path_tail:
rel_path = "{}/".format(path_tail)
path_tail = path[0][path_tail_idx:]

# if this entry is the package top dir, keep it
# empty so we don't double append the dir name
if filename not in path_tail:
rel_path = "{}/".format(path_tail)

for path_files in path[2]:
walked_files.append("{}{}".format(rel_path, path_files))
Expand All @@ -151,8 +155,8 @@ def library(library_path, output_directory, package_folder_prefix,
#print("- package files: {} | {}".format(filename, package_files))

if (filename.endswith(".py") and
filename not in IGNORE_PY and
not example_bundle):
filename not in IGNORE_PY and
not example_bundle):
py_files.append(filename)

if len(py_files) > 1:
Expand Down