Skip to content

Commit daa330c

Browse files
author
Nathan Ogden
committed
change file persmissions so allow executable binaries during build; add configuration param to allow inclusion of additional directories in build
1 parent 84ffeec commit daa330c

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

aws_lambda/aws_lambda.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys
77
import time
88
from imp import load_source
9-
from shutil import copy, copyfile
9+
from shutil import copy, copyfile, copytree
1010
from tempfile import mkdtemp
1111

1212
import botocore
@@ -207,6 +207,17 @@ def build(src, requirements=False, local_package=None):
207207
print("Bundling: %r" % filename)
208208
files.append(os.path.join(src, filename))
209209

210+
# include additional directories
211+
include_paths = cfg.get('include_directories', [])
212+
for include_path in include_paths:
213+
if not os.path.isdir(include_path):
214+
continue
215+
print("Bundling: %r" % include_path)
216+
copytree(
217+
include_path,
218+
os.path.join(path_to_temp, include_path)
219+
)
220+
210221
# "cd" into `temp_path` directory.
211222
os.chdir(path_to_temp)
212223
for f in files:

aws_lambda/helpers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# -*- coding: utf-8 -*-
22
import os
3+
import stat
34
import zipfile
45
import datetime as dt
56

6-
77
def mkdir(path):
88
if not os.path.exists(path):
99
os.makedirs(path)
@@ -22,7 +22,12 @@ def archive(src, dest, filename):
2222

2323
for root, _, files in os.walk(src):
2424
for file in files:
25-
zfh.write(os.path.join(root, file))
25+
filePath = os.path.join(root, file)
26+
zfh.write(filePath)
27+
# set global read+write+execute permissions (needed to execute binaries)
28+
# TODO: set permission from file
29+
info = zfh.getinfo(filePath.strip("./"))
30+
info.external_attr = 0777 << 16L
2631
zfh.close()
2732
return os.path.join(dest, filename)
2833

0 commit comments

Comments
 (0)