@@ -29,22 +29,11 @@ def deploy(src):
29
29
path_to_config_file = os .path .join (src , 'config.yaml' )
30
30
cfg = read (path_to_config_file , loader = yaml .load )
31
31
32
- # Get the absolute path to the output directory and create it if it doesn't
33
- # already exist.
34
- dist_directory = cfg .get ('dist_directory' , 'dist' )
35
- path_to_dist = os .path .join (src , dist_directory )
36
- mkdir (path_to_dist )
37
-
38
- # Combine the name of the Lambda function with the current timestamp to use
39
- # for the output filename.
40
- function_name = cfg .get ('function_name' )
41
- output_filename = "{0}-{1}.zip" .format (timestamp (), function_name )
42
-
43
32
# Copy all the pip dependencies required to run your code into a temporary
44
33
# folder then add the handler file in the root of this directory.
45
34
# Zip the contents of this folder into a single file and output to the dist
46
35
# directory.
47
- path_to_zip_file = build (src , path_to_dist , output_filename )
36
+ path_to_zip_file = build (src )
48
37
49
38
if function_exists (cfg , cfg .get ('function_name' )):
50
39
update_function (cfg , path_to_zip_file )
@@ -112,7 +101,7 @@ def init(src, minimal=False):
112
101
copy (path_to_file , src )
113
102
114
103
115
- def build (src , path_to_dist , output_filename ):
104
+ def build (src ):
116
105
"""Builds the file bundle.
117
106
118
107
:param str path_to_handler_file:
@@ -126,6 +115,17 @@ def build(src, path_to_dist, output_filename):
126
115
path_to_config_file = os .path .join (src , 'config.yaml' )
127
116
cfg = read (path_to_config_file , loader = yaml .load )
128
117
118
+ # Get the absolute path to the output directory and create it if it doesn't
119
+ # already exist.
120
+ dist_directory = cfg .get ('dist_directory' , 'dist' )
121
+ path_to_dist = os .path .join (src , dist_directory )
122
+ mkdir (path_to_dist )
123
+
124
+ # Combine the name of the Lambda function with the current timestamp to use
125
+ # for the output filename.
126
+ function_name = cfg .get ('function_name' )
127
+ output_filename = "{0}-{1}.zip" .format (timestamp (), function_name )
128
+
129
129
path_to_temp = mkdtemp (prefix = 'aws-lambda' )
130
130
pip_install_to_target (path_to_temp )
131
131
@@ -134,18 +134,22 @@ def build(src, path_to_dist, output_filename):
134
134
if not output_filename .endswith ('.zip' )
135
135
else output_filename )
136
136
137
- # Determine the filename and absolute path to the handler module.
138
- handler = cfg .get ('handler' )
139
- filename = get_handler_filename (handler )
140
- path_to_handler_file = os .path .join (src , filename )
137
+ files = []
138
+ for filename in os .listdir (src ):
139
+ if os .path .isfile (filename ):
140
+ if filename == '.DS_Store' :
141
+ continue
142
+ if filename == 'config.yaml' :
143
+ continue
144
+ files .append (os .path .join (src , filename ))
141
145
142
146
# "cd" into `temp_path` directory.
143
147
os .chdir (path_to_temp )
148
+ for f in files :
149
+ _ , filename = os .path .split (f )
144
150
145
- _ , filename = os .path .split (path_to_handler_file )
146
-
147
- # Copy handler file into root of the packages folder.
148
- copyfile (path_to_handler_file , os .path .join (path_to_temp , filename ))
151
+ # Copy handler file into root of the packages folder.
152
+ copyfile (f , os .path .join (path_to_temp , filename ))
149
153
150
154
# Zip them together into a single file.
151
155
# TODO: Delete temp directory created once the archive has been compiled.
0 commit comments