Skip to content
This repository was archived by the owner on Mar 15, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Related to issue #64 "Subdirectories not included in zip pack…
…age"."

This reverts commit 893e6e8.
  • Loading branch information
asaolabs committed Sep 13, 2017
commit 028713e7d4470096e3141184f76fdac22ca3fa34
25 changes: 8 additions & 17 deletions aws_lambda/aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
import time
from imp import load_source
from shutil import copy
from shutil import copyfile, copytree
from shutil import copyfile
from tempfile import mkdtemp
from collections import defaultdict

import boto3
import botocore
Expand Down Expand Up @@ -243,32 +242,24 @@ def build(src, requirements=False, local_package=None):
else output_filename
)

# Allow definition of source code directories we want to build into our zipped package.
build_config = defaultdict(**cfg.get('build', {}))
source_directories = [d.strip() for d in build_config.get('source_directories', '').split(',')]

files = []
for filename in os.listdir(src):
if os.path.isfile(filename):
if filename == '.DS_Store':
continue
if filename == 'config.yaml':
continue
elif os.path.isdir(filename) and filename in source_directories:
print('Bundling directory: %r' % filename)
files.append(os.path.join(src, filename))
# TODO: Check subdirectories for '.DS_Store' files
print('Bundling: %r' % filename)
files.append(os.path.join(src, filename))

# "cd" into `temp_path` directory.
os.chdir(path_to_temp)
for f in files:
if os.path.isfile(f):
_, filename = os.path.split(f)

# Copy handler file into root of the packages folder.
copyfile(f, os.path.join(path_to_temp, filename))
elif os.path.isdir(f):
destination_folder = os.path.join(path_to_temp, f[len(src) + 1:])
copytree(f, destination_folder)
_, filename = os.path.split(f)

# Copy handler file into root of the packages folder.
copyfile(f, os.path.join(path_to_temp, filename))

# Zip them together into a single file.
# TODO: Delete temp directory created once the archive has been compiled.
Expand Down
4 changes: 0 additions & 4 deletions aws_lambda/project_templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,3 @@ aws_secret_access_key:
environment_variables:
env_1: foo
env_2: baz

# Build options
build:
include_source_directories: lib # a common delimited list of directories in your project root that contains source to package.