@@ -139,6 +139,13 @@ def library(library_path, output_directory, package_folder_prefix,
139
139
raise ValueError ("Multiple top level py files not allowed. Please put "
140
140
"them in a package or combine them into a single file." )
141
141
142
+ if package_files :
143
+ module_name = package_files [0 ].relative_to (library_path ).parent .name
144
+ elif py_files :
145
+ module_name = py_files [0 ].relative_to (library_path ).name [:- 3 ]
146
+ else :
147
+ module_name = None
148
+
142
149
for fn in example_files :
143
150
base_dir = os .path .join (output_directory .replace ("/lib" , "/" ),
144
151
fn .relative_to (library_path ).parent )
@@ -208,6 +215,22 @@ def library(library_path, output_directory, package_folder_prefix,
208
215
if mpy_success != 0 :
209
216
raise RuntimeError ("mpy-cross failed on" , full_path )
210
217
218
+ requirements_files = lib_path .glob ("requirements.txt*" )
219
+ requirements_files = [f for f in requirements_files if f .stat ().st_size > 0 ]
220
+ if module_name and requirements_files and not example_bundle :
221
+ requirements_dir = pathlib .Path (output_directory ).parent / "requirements"
222
+ if not os .path .isdir (requirements_dir ):
223
+ os .makedirs (requirements_dir , exist_ok = True )
224
+ total_size += 512
225
+ requirements_subdir = f"{ requirements_dir } /{ module_name } "
226
+ if not os .path .isdir (requirements_subdir ):
227
+ os .makedirs (requirements_subdir , exist_ok = True )
228
+ total_size += 512
229
+ for filename in requirements_files :
230
+ full_path = os .path .join (library_path , filename )
231
+ output_file = os .path .join (requirements_subdir , "requirements.txt" )
232
+ shutil .copyfile (full_path , output_file )
233
+
211
234
for filename in example_files :
212
235
full_path = os .path .join (library_path , filename )
213
236
output_file = os .path .join (output_directory .replace ("/lib" , "/" ),
0 commit comments