Skip to content

Commit 1f3c5bd

Browse files
authored
Merge pull request #116 from FoamyGuy/example_subdirs
example subdirectories
2 parents 4f7f0b8 + d1d1709 commit 1f3c5bd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

circuitpython_build_tools/build.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,6 @@ def library(library_path, output_directory, package_folder_prefix,
276276
example_files = package_info["example_files"]
277277
module_name = package_info["module_name"]
278278

279-
for fn in example_files:
280-
base_dir = os.path.join(output_directory.replace("/lib", "/"),
281-
fn.relative_to(library_path).parent)
282-
if not os.path.isdir(base_dir):
283-
os.makedirs(base_dir)
284-
285279
for fn in py_package_files:
286280
base_dir = os.path.join(output_directory,
287281
fn.relative_to(library_path).parent)
@@ -338,6 +332,12 @@ def library(library_path, output_directory, package_folder_prefix,
338332

339333
for filename in example_files:
340334
full_path = os.path.join(library_path, filename)
335+
336+
relative_filename_parts = list(filename.relative_to(library_path).parts)
337+
relative_filename_parts.insert(1, library_path.split(os.path.sep)[-1])
338+
final_relative_filename = os.path.join(*relative_filename_parts)
341339
output_file = os.path.join(output_directory.replace("/lib", "/"),
342-
filename.relative_to(library_path))
340+
final_relative_filename)
341+
342+
os.makedirs(os.path.join(*output_file.split(os.path.sep)[:-1]), exist_ok=True)
343343
shutil.copyfile(full_path, output_file)

0 commit comments

Comments
 (0)