'Create a Lambda-ready zip file of the current virtualenvironment and working directory.
Returns path to that file.'

def create_lambda_zip(self, prefix='lambda_package', handler_file=None, slim_handler=False, minify=True, exclude=None, use_precompiled_packages=True, include=None, venv=None, output=None, disable_progress=False):

    import pip
    if (not venv):
        venv = self.get_current_venv()
    cwd = os.getcwd()
    if (not output):
        zip_fname = (((prefix + '-') + str(int(time.time()))) + '.zip')
    else:
        zip_fname = output
    zip_path = os.path.join(cwd, zip_fname)
    if (exclude is None):
        exclude = list()
    exclude.append(zip_path)
    if (not ('concurrent' in exclude)):
        exclude.append('concurrent')
    def splitpath(path):
        parts = []
        (path, tail) = os.path.split(path)
        while (path and tail):
            parts.append(tail)
            (path, tail) = os.path.split(path)
        parts.append(os.path.join(path, tail))
        return list(map(os.path.normpath, parts))[::(-1)]
    split_venv = splitpath(venv)
    split_cwd = splitpath(cwd)
    if (split_venv[(-1)] == split_cwd[(-1)]):
        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.")
    temp_project_path = os.path.join(tempfile.gettempdir(), str(int(time.time())))
    os.makedirs(temp_project_path)
    if (not slim_handler):
        if minify:
            excludes = ((ZIP_EXCLUDES + exclude) + [split_venv[(-1)]])
            copytree(cwd, temp_project_path, symlinks=False, ignore=shutil.ignore_patterns(*excludes))
        else:
            copytree(cwd, temp_project_path, symlinks=False)
    if handler_file:
        filename = handler_file.split(os.sep)[(-1)]
        shutil.copy(handler_file, os.path.join(temp_project_path, filename))
    egg_links = []
    temp_package_path = os.path.join(tempfile.gettempdir(), str(int((time.time() + 1))))
    if (os.sys.platform == 'win32'):
        site_packages = os.path.join(venv, 'Lib', 'site-packages')
    else:
        site_packages = os.path.join(venv, 'lib', get_venv_from_python_version(), 'site-packages')
    egg_links.extend(glob.glob(os.path.join(site_packages, '*.egg-link')))
    if minify:
        excludes = (ZIP_EXCLUDES + exclude)
        copytree(site_packages, temp_package_path, symlinks=False, ignore=shutil.ignore_patterns(*excludes))
    else:
        copytree(site_packages, temp_package_path, symlinks=False)
    site_packages_64 = os.path.join(venv, 'lib64', get_venv_from_python_version(), 'site-packages')
    if os.path.exists(site_packages_64):
        egg_links.extend(glob.glob(os.path.join(site_packages_64, '*.egg-link')))
        if minify:
            excludes = (ZIP_EXCLUDES + exclude)
            copytree(site_packages_64, temp_package_path, symlinks=False, ignore=shutil.ignore_patterns(*excludes))
        else:
            copytree(site_packages_64, temp_package_path, symlinks=False)
    if egg_links:
        self.copy_editable_packages(egg_links, temp_package_path)
    copy_tree(temp_package_path, temp_project_path, update=True)
    if use_precompiled_packages:
        print('Downloading    and    installing    dependencies..')
        installed_packages = self.get_installed_packages(site_packages, site_packages_64)
        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(('    -    %s==%s:    Using    precompiled    lambda    package    ' % (installed_package_name, installed_package_version)))
                    self.extract_lambda_package(installed_package_name, temp_project_path)
                else:
                    cached_wheel_path = self.get_cached_manylinux_wheel(installed_package_name, installed_package_version, disable_progress)
                    if cached_wheel_path:
                        shutil.rmtree(os.path.join(temp_project_path, installed_package_name), ignore_errors=True)
                        with zipfile.ZipFile(cached_wheel_path) as zfile:
                            zfile.extractall(temp_project_path)
                    elif self.have_any_lambda_package_version(installed_package_name):
                        lambda_version = lambda_packages[installed_package_name][self.runtime]['version']
                        print(('    -    %s==%s:    Warning!    Using    precompiled    lambda    package    version    %s    instead!' % (installed_package_name, installed_package_version, lambda_version)))
                        self.extract_lambda_package(installed_package_name, temp_project_path)
        except Exception as e:
            print(e)
    print('Packaging    project    as    zip..')
    try:
        compression_method = zipfile.ZIP_DEFLATED
    except ImportError:
        compression_method = zipfile.ZIP_STORED
    zipf = zipfile.ZipFile(zip_path, 'w', compression_method)
    for (root, dirs, files) in os.walk(temp_project_path):
        for filename in files:
            if ((filename[(-4):] == '.pyc') and (root[(-10):] == 'migrations')):
                continue
            if ((filename[(-3):] == '.py') and (root[(-10):] != 'migrations')):
                abs_filname = os.path.join(root, filename)
                abs_pyc_filename = (abs_filname + 'c')
                if os.path.isfile(abs_pyc_filename):
                    py_time = os.stat(abs_filname).st_mtime
                    pyc_time = os.stat(abs_pyc_filename).st_mtime
                    if (pyc_time > py_time):
                        continue
            os.chmod(os.path.join(root, filename), 493)
            zipi = zipfile.ZipInfo(os.path.join(root.replace(temp_project_path, '').lstrip(os.sep), filename))
            zipi.create_system = 3
            zipi.external_attr = (493 << int(16))
            with open(os.path.join(root, filename), 'rb') as f:
                zipf.writestr(zipi, f.read(), compression_method)
        if (not contains_python_files_or_subdirs(root)):
            dirs[:] = [d for d in dirs if (d != root)]
        elif (('__init__.py' not in files) and (not conflicts_with_a_neighbouring_module(root))):
            tmp_init = os.path.join(temp_project_path, '__init__.py')
            open(tmp_init, 'a').close()
            os.chmod(tmp_init, 493)
            zipf.write(tmp_init, os.path.join(root.replace(temp_project_path, ''), os.path.join(root.replace(temp_project_path, ''), '__init__.py')))
    zipf.close()
    shutil.rmtree(temp_project_path)
    shutil.rmtree(temp_package_path)
    if (os.path.isdir(venv) and slim_handler):
        shutil.rmtree(venv)
    return zip_fname
