in aws_lambda_builders/workflows/python_pip/packager.py [0:0]
def download_all_dependencies(self, requirements_filename, directory):
"""Download all dependencies as sdist or wheel."""
arguments = ["-r", requirements_filename, "--dest", directory, "--exists-action", "i"]
rc, out, err = self._execute("download", arguments)
# When downloading all dependencies we expect to get an rc of 0 back
# since we are casting a wide net here letting pip have options about
# what to download. If a package is not found it is likely because it
# does not exist and was mispelled. In this case we raise an error with
# the package name. Otherwise a nonzero rc results in a generic
# download error where we pass along the stderr.
if rc != 0:
if err is None:
err = b"Unknown error"
error = err.decode()
match = re.search(("Could not find a version that satisfies the " "requirement (.+?) "), error)
if match:
package_name = match.group(1)
raise NoSuchPackageError(str(package_name))
raise PackageDownloadError(error)
# Extract local packages from pip output.
# Iterate over possible pip outputs depending on pip version.
stdout = out.decode()
wheel_package_paths = set()
for pattern in self._LINK_IS_DIR_PATTERNS:
for match in re.finditer(pattern, stdout):
wheel_package_paths.add(str(match.group(1)))
for wheel_package_path in wheel_package_paths:
# Looks odd we do not check on the error status of building the
# wheel here. We can assume this is a valid package path since
# we already passed the pip download stage. This stage would have
# thrown a PackageDownloadError if any of the listed packages were
# not valid.
# If it fails the actual build step, it will have the same behavior
# as any other package we fail to build a valid wheel for, and
# complain at deployment time.
self.build_wheel(wheel_package_path, directory)