@@ -321,16 +321,36 @@ def make_package(args):
321
321
'full private data into .apk.' )
322
322
tar_dirs .append (args .private )
323
323
else :
324
- print (' Copying main.py ONLY, since other app data is '
325
- ' expected in site-packages.' )
324
+ print (" Copying main.py's ONLY, since other app data is "
325
+ " expected in site-packages." )
326
326
main_py_only_dir = tempfile .mkdtemp ()
327
327
_temp_dirs_to_clean .append (main_py_only_dir )
328
- if exists (join (args .private , "main.pyo" )):
329
- shutil .copyfile (join (args .private , "main.pyo" ),
330
- join (main_py_only_dir , "main.pyo" ))
331
- elif exists (join (args .private , "main.py" )):
332
- shutil .copyfile (join (args .private , "main.py" ),
333
- join (main_py_only_dir , "main.py" ))
328
+
329
+ # Check all main.py files we need to copy:
330
+ copy_paths = ["main.py" , join ("service" , "main.py" )]
331
+ for copy_path in copy_paths :
332
+ variants = [
333
+ copy_path ,
334
+ copy_path .partition ("." )[0 ] + ".pyc" ,
335
+ copy_path .partition ("." )[0 ] + ".pyo" ,
336
+ ]
337
+ # Check in all variants with all possible endings:
338
+ for variant in variants :
339
+ if exists (join (args .private , variant )):
340
+ # Make sure surrounding directly exists:
341
+ dir_path = os .path .dirname (variant )
342
+ if (len (dir_path ) > 0 and
343
+ not exists (
344
+ join (main_py_only_dir , dir_path )
345
+ )):
346
+ os .mkdir (join (main_py_only_dir , dir_path ))
347
+ # Copy actual file:
348
+ shutil .copyfile (
349
+ join (args .private , variant ),
350
+ join (main_py_only_dir , variant ),
351
+ )
352
+
353
+ # Append directory with all main.py's to result apk paths:
334
354
tar_dirs .append (main_py_only_dir )
335
355
for python_bundle_dir in ('private' , '_python_bundle' ):
336
356
if exists (python_bundle_dir ):
0 commit comments