@@ -62,7 +62,7 @@ def cleanup_old_versions(src, keep_last_versions):
6262 e .message ))
6363
6464
65- def deploy (src , local_package = None ):
65+ def deploy (src , local_package = None , copy_file = None ):
6666 """Deploys a new function to AWS Lambda.
6767
6868 :param str src:
@@ -80,7 +80,7 @@ def deploy(src, local_package=None):
8080 # folder then add the handler file in the root of this directory.
8181 # Zip the contents of this folder into a single file and output to the dist
8282 # directory.
83- path_to_zip_file = build (src , local_package )
83+ path_to_zip_file = build (src , local_package , copy_file )
8484
8585 if function_exists (cfg , cfg .get ('function_name' )):
8686 update_function (cfg , path_to_zip_file )
@@ -146,7 +146,7 @@ def init(src, minimal=False):
146146 copy (destination , src )
147147
148148
149- def build (src , local_package = None ):
149+ def build (src , local_package = None , copy_file = None ):
150150 """Builds the file bundle.
151151
152152 :param str src:
@@ -196,6 +196,20 @@ def build(src, local_package=None):
196196 # Copy handler file into root of the packages folder.
197197 copyfile (f , os .path .join (path_to_temp , filename ))
198198
199+ if copy_file :
200+ if os .path .isfile (copy_file ):
201+ copyfile (copy_file ,
202+ os .path .join (path_to_temp , os .path .basename (copy_file )))
203+ elif os .path .isdir (copy_file ):
204+ copy_dir_name = os .path .basename (copy_file )
205+ dest_dir = os .path .join (path_to_temp , copy_dir_name )
206+
207+ from shutil import rmtree , copytree
208+
209+ if os .path .exists (dest_dir ):
210+ rmtree (dest_dir )
211+ copytree (copy_file , dest_dir )
212+
199213 # Zip them together into a single file.
200214 # TODO: Delete temp directory created once the archive has been compiled.
201215 path_to_zip_file = archive ('./' , path_to_dist , output_filename )
0 commit comments