diff --git a/zappa/zappa.py b/zappa/zappa.py index 735348ae2..6146f455f 100755 --- a/zappa/zappa.py +++ b/zappa/zappa.py @@ -265,7 +265,7 @@ def create_lambda_zip(self, prefix='lambda_package', handler_file=None, warnings.warn('The local python version is different than that of AWS lambda (2.7.x).\nMake sure the binaries in your conda environment are compatible with AWS lambda') if use_precompiled_packages: warnings.warn('Using conda while use_precompiled_packages is set to true is not recommended: it may lead to overwriting conda packages') - + USE_CONDA = conda_env is not None cwd = os.getcwd() zip_fname = prefix + '-' + str(int(time.time())) + '.zip' @@ -295,7 +295,8 @@ def splitpath(path): print("Warning! Your project and virtualenv have the same name! You may want to re-create your venv with a new name, or explicitly define a 'project_name', as this may cause errors.") # First, do the project.. - temp_project_path = os.path.join(tempfile.gettempdir(), str(int(time.time()))) + temp_zappa_folder = os.path.join(tempfile.gettempdir(), str(int(time.time()))) + temp_project_path = os.path.join(temp_zappa_folder, 'project') if minify: excludes = ZIP_EXCLUDES + exclude + [split_venv[-1]] @@ -305,7 +306,7 @@ def splitpath(path): # Then, do the site-packages.. # TODO Windows: %VIRTUAL_ENV%\Lib\site-packages - temp_package_path = os.path.join(tempfile.gettempdir(), str(int(time.time() + 1))) + temp_package_path = os.path.join(temp_zappa_folder, 'package') site_packages = os.path.join(venv, 'lib', 'python2.7', 'site-packages') if minify: @@ -371,8 +372,7 @@ def splitpath(path): zipf.close() # Trash the temp directory - shutil.rmtree(temp_project_path) - shutil.rmtree(temp_package_path) + shutil.rmtree(temp_zappa_folder) # Warn if this is too large for Lambda. file_stats = os.stat(zip_path)