Skip to content

Commit 14857bc

Browse files
committed
support for embedding binaries
1 parent e980edc commit 14857bc

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

aws_lambda/aws_lambda.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -166,34 +166,22 @@ def build(src, requirements=False, local_package=None, raw_copy=None):
166166
path_to_dist = os.path.join(src, dist_directory)
167167
mkdir(path_to_dist)
168168

169+
path_to_temp = mkdtemp(prefix='aws-lambda')
170+
171+
if raw_copy:
172+
bin_dir = os.path.join(path_to_temp, "lambda_bin")
173+
import shutil
174+
shutil.copytree(raw_copy, bin_dir)
175+
169176
# Combine the name of the Lambda function with the current timestamp to use
170177
# for the output filename.
171178
function_name = cfg.get('function_name')
172179
output_filename = "{0}-{1}.zip".format(timestamp(), function_name)
173180

174-
path_to_temp = mkdtemp(prefix='aws-lambda')
175181
pip_install_to_target(path_to_temp,
176182
requirements=requirements,
177183
local_package=local_package)
178184

179-
if raw_copy:
180-
raw_files = []
181-
for filename in os.listdir(raw_copy):
182-
if os.path.isfile(filename):
183-
if filename == '.DS_Store':
184-
continue
185-
if filename == 'config.yaml':
186-
continue
187-
raw_files.append(os.path.join(src, filename))
188-
189-
# "cd" into `temp_path` directory.
190-
os.chdir(path_to_temp)
191-
for f in raw_files:
192-
_, filename = os.path.split(f)
193-
194-
# Copy handler file into root of the packages folder.
195-
copyfile(f, os.path.join(path_to_temp, filename))
196-
197185

198186
# Gracefully handle whether ".zip" was included in the filename or not.
199187
output_filename = ('{0}.zip'.format(output_filename)

0 commit comments

Comments
 (0)