def _build_downloader(target_directory):
"""Build the downloader Lambda deployment package."""
print('Creating downloader deploy package...')
pathlib.Path(DOWNLOAD_SOURCE).touch()
temp_package_dir = os.path.join(tempfile.gettempdir(), 'tmp_yara_downloader.pkg')
if os.path.exists(temp_package_dir):
shutil.rmtree(temp_package_dir)
# Extract cbapi library.
with zipfile.ZipFile(DOWNLOAD_DEPENDENCIES, 'r') as deps:
deps.extractall(temp_package_dir)
# Pip install backoff library (has no native dependencies).
pip.main(['install', '--quiet', '--target', temp_package_dir, 'backoff'])
# Copy Lambda code into the package.
shutil.copy(DOWNLOAD_SOURCE, temp_package_dir)
# Zip up the package and remove temporary directory.
shutil.make_archive(os.path.join(target_directory, DOWNLOAD_ZIPFILE), 'zip', temp_package_dir)
shutil.rmtree(temp_package_dir)
评论列表
文章目录