Skip to content

Commit 800ee1a

Browse files
authored
Merge pull request #44 from sommersoft/fix_subfolder
Retain Full Subfolder Structure In Packages
2 parents 930c053 + 8175c6c commit 800ee1a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

circuitpython_build_tools/build.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ def _munge_to_temp(original_path, temp_file, library_version):
100100
temp_file.write(line.encode("utf-8") + b"\r\n")
101101
temp_file.flush()
102102

103-
def library(library_path, output_directory, package_folder_prefix, mpy_cross=None, example_bundle=False):
103+
def library(library_path, output_directory, package_folder_prefix,
104+
mpy_cross=None, example_bundle=False):
104105
py_files = []
105106
package_files = []
106107
example_files = []
@@ -118,7 +119,8 @@ def library(library_path, output_directory, package_folder_prefix, mpy_cross=Non
118119
if filename.startswith("examples"):
119120
path_tail_idx = path[0].rfind("examples/") + 9
120121
else:
121-
path_tail_idx = path[0].rfind("/") + 1
122+
path_tail_idx = (path[0].rfind("{}/".format(filename))
123+
+ (len(filename) +1))
122124
path_tail = path[0][path_tail_idx:]
123125
rel_path = ""
124126
# if this entry is the package top dir, keep it
@@ -130,7 +132,10 @@ def library(library_path, output_directory, package_folder_prefix, mpy_cross=Non
130132
walked_files.append("{}{}".format(rel_path, path_files))
131133
#print(" - expanded file walk: {}".format(walked_files))
132134

133-
files = filter(lambda x: x.endswith(".py") or x.startswith("font5x8.bin"), walked_files)
135+
files = filter(
136+
lambda x: x.endswith(".py") or x.startswith("font5x8.bin"),
137+
walked_files
138+
)
134139
files = map(lambda x: os.path.join(filename, x), files)
135140

136141
if filename.startswith("examples"):
@@ -139,7 +144,7 @@ def library(library_path, output_directory, package_folder_prefix, mpy_cross=Non
139144
else:
140145
if (not example_bundle and
141146
not filename.startswith(package_folder_prefix)):
142-
#print("skipped path: {}".format(full_path))
147+
print("skipped path: {}".format(full_path))
143148
continue
144149
if not example_bundle:
145150
package_files.extend(files)

0 commit comments

Comments
 (0)