Skip to content

example subdirectories #116

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
Apr 9, 2024
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
14 changes: 7 additions & 7 deletions circuitpython_build_tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,6 @@ def library(library_path, output_directory, package_folder_prefix,
example_files = package_info["example_files"]
module_name = package_info["module_name"]

for fn in example_files:
base_dir = os.path.join(output_directory.replace("/lib", "/"),
fn.relative_to(library_path).parent)
if not os.path.isdir(base_dir):
os.makedirs(base_dir)

for fn in py_package_files:
base_dir = os.path.join(output_directory,
fn.relative_to(library_path).parent)
Expand Down Expand Up @@ -338,6 +332,12 @@ def library(library_path, output_directory, package_folder_prefix,

for filename in example_files:
full_path = os.path.join(library_path, filename)

relative_filename_parts = list(filename.relative_to(library_path).parts)
relative_filename_parts.insert(1, library_path.split(os.path.sep)[-1])
final_relative_filename = os.path.join(*relative_filename_parts)
output_file = os.path.join(output_directory.replace("/lib", "/"),
filename.relative_to(library_path))
final_relative_filename)

os.makedirs(os.path.join(*output_file.split(os.path.sep)[:-1]), exist_ok=True)
shutil.copyfile(full_path, output_file)