Skip to content

Commit

Permalink
Make excluded conda packages configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieu1 committed May 27, 2016
1 parent 618aa8e commit 2916e9e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -156,6 +156,7 @@ to change Zappa's behavior. Use these at your own risk!
}],
"domain": "yourapp.yourdomain.com", // Required if you're using a domain
"exclude": ["*.gz", "*.pem"], // A list of regex patterns to exclude from the archive
"exclude_conda_packages": ["boto3","botocore","pip","python","readline","sqlite","wheel"] // When using conda, a list of conda packages to remove before zipping.
"http_methods": ["GET", "POST"], // HTTP Methods to route,
"integration_response_codes": [200, 301, 404, 500], // Integration response status codes to route
"keep_warm": true, // Create CloudWatch events to keep the server warm.
Expand All @@ -172,7 +173,7 @@ to change Zappa's behavior. Use these at your own risk!
"vpc_config": { // Optional VPC configuration for Lambda function
"SubnetIds": [ "subnet-12345678" ], // Note: not all availability zones support Lambda!
"SecurityGroupIds": [ "sg-12345678" ]
}
},
}
}
```
Expand Down
4 changes: 3 additions & 1 deletion zappa/cli.py
Expand Up @@ -450,7 +450,9 @@ def create_package(self):
self.lambda_name,
handler_file=handler_file,
use_precompiled_packages=self.zappa_settings[self.api_stage].get('use_precompiled_packages', True),
exclude=self.zappa_settings[self.api_stage].get('exclude', [])
exclude=self.zappa_settings[self.api_stage].get('exclude', []),
exclude_conda_packages = self.zappa_settings[self.api_stage].get('exclude_conda_packages',
['pip','python','readline','sqlite','wheel', 'boto3', 'botocore'])
)

# Throw our setings into it
Expand Down
8 changes: 4 additions & 4 deletions zappa/zappa.py
Expand Up @@ -179,8 +179,6 @@

ZIP_EXCLUDES = ['*.exe', '*.DS_Store', '*.Python', '*.git', '*.zip', '*.tar.gz','*.hg']

STANDARD_CONDA_PACKAGES = ['openssl','pip','python','readline','sqlite','wheel', 'boto3', 'botocore']

##
# Classes
##
Expand Down Expand Up @@ -239,7 +237,8 @@ def __init__(self, boto_session=None, profile_name=None):
##

def create_lambda_zip(self, prefix='lambda_package', handler_file=None,
minify=True, exclude=None, use_precompiled_packages=True, include=None, venv=None, exclude_conda_packages=STANDARD_CONDA_PACKAGES):
minify=True, exclude=None, use_precompiled_packages=True, include=None, venv=None,
exclude_conda_packages=[]):
"""
Creates a Lambda-ready zip file of the current virtualenvironment and working directory.
Expand Down Expand Up @@ -327,7 +326,8 @@ def splitpath(path):
excludes = ZIP_EXCLUDES + exclude
shutil.copytree(conda_env, temp_package_path, symlinks=True, ignore=shutil.ignore_patterns(*excludes))
# Use conda cli to remove standard packages like python, pip, ...
subprocess.call(['conda','remove','-p',temp_package_path,'--force','--yes']+exclude_conda_packages)
if len(exclude_conda_packages):
subprocess.call(['conda','remove','-p',temp_package_path,'--force','--yes']+exclude_conda_packages)
else:
shutil.copytree(conda_env, temp_package_path, symlinks=True)

Expand Down

0 comments on commit 2916e9e

Please sign in to comment.