Repository: Miserlou/Zappa

Issue:
installed_packages is lowercase, but lambda_packages are case sensitive
<!--- Provide a general summary of the issue in the Title above -->
## Context
<!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug -->
<!--- Also, please make sure that you are running Zappa _from a virtual environment_ and are using Python 2.7 --> 

It seems introduced in c1550cf8 installed_packages returns a package.lower() set of keys, but when looking in lambda_packages it therefore misses the key that is case-sensitive in lambda_packages

## Expected Behavior
<!--- Tell us what should happen -->
When searching, for e.g. `MySQL-Python`, lambda_packages.get() should return the right package

## Actual Behavior
<!--- Tell us what happens instead -->
...., but it isn't found because installed_packages has `mysql-python`

## Possible Fix
<!--- Not obligatory, but suggest a fix or reason for the bug -->
We could see this as either a bug in Zappa or in lambda_packages.  I'm tempted to suggest we keep this in Zappa, since it's doing the lower-casing, and any other dependencies of `lambda_packages` would break past key lookups

## Steps to Reproduce
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug include code to reproduce, if relevant -->
1. Use a project with MySQL-Python as a dependency
2. note that `zappa package` doesn't load it in from lambda_packages

## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Zappa version used: 8e2e20fc1378998d6b2c4ac8c3253d03f681b5c7
* Operating System and Python version: 2.7 (Ubuntu)




Discussion:

Resolving patch:
diff --git a/zappa/core.py b/zappa/core.py
--- a/zappa/core.py
+++ b/zappa/core.py
@@ -22,7 +22,7 @@
 from botocore.exceptions import ClientError
 from distutils.dir_util import copy_tree
 from io import BytesIO, open
-from lambda_packages import lambda_packages
+from lambda_packages import lambda_packages as lambda_packages_orig
 from setuptools import find_packages
 from tqdm import tqdm
 
@@ -44,6 +44,10 @@
 logger.setLevel(logging.INFO)
 
 
+# We lower-case lambda package keys to match lower-cased keys in get_installed_packages()
+lambda_packages = {package_name.lower():val
+                   for package_name,val in lambda_packages_orig.items()}
+
 ##
 # Policies And Template Mappings
 ##
@@ -482,7 +486,6 @@ def splitpath(path):
 
             try:
                 for installed_package_name, installed_package_version in installed_packages.items():
-
                     if self.have_correct_lambda_package_version(installed_package_name, installed_package_version):
                         print("Using lambda_packages binary for %s %s" % (installed_package_name, installed_package_version,))
                         self.extract_lambda_package(installed_package_name, temp_project_path)
@@ -612,6 +615,7 @@ def get_installed_packages(site_packages, site_packages_64):
     def have_correct_lambda_package_version(self, package_name, package_version):
         """
         Checks if a given package version binary should be copied over from lambda packages.
+        package_name should be lower-cased version of package name.
         """
         lambda_package_details = lambda_packages.get(package_name, {}).get(self.runtime)
 
@@ -628,6 +632,7 @@ def have_correct_lambda_package_version(self, package_name, package_version):
     def have_any_lambda_package_version(self, package_name):
         """
         Checks if a given package has any lambda package version. We can try and use it with a warning.
+        package_name should be lower-cased version of package name.
         """
         return lambda_packages.get(package_name, {}).get(self.runtime) is not None
 


Test patch: