Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion aws_lambda_builders/workflows/python_pip/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ class PythonPipBuildAction(BaseAction):
DESCRIPTION = "Installing dependencies from PIP"
PURPOSE = Purpose.RESOLVE_DEPENDENCIES

def __init__(self, artifacts_dir, manifest_path, runtime):
def __init__(self, artifacts_dir, manifest_path, scratch_dir, runtime):
self.artifacts_dir = artifacts_dir
self.manifest_path = manifest_path
self.scratch_dir = scratch_dir
self.runtime = runtime
self.package_builder = PythonPipDependencyBuilder()

Expand All @@ -23,6 +24,7 @@ def execute(self):
self.package_builder.build_dependencies(
self.artifacts_dir,
self.manifest_path,
self.scratch_dir,
self.runtime,
)
except PackagerError as ex:
Expand Down
23 changes: 15 additions & 8 deletions aws_lambda_builders/workflows/python_pip/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,16 @@ def __init__(self, osutils=None, dependency_builder=None):
dependency_builder = DependencyBuilder(self.osutils)
self._dependency_builder = dependency_builder

def build_dependencies(self, artifacts_dir_path, requirements_path,
runtime, ui=None, config=None):
def build_dependencies(self, artifacts_dir_path, scratch_dir_path,
requirements_path, runtime, ui=None, config=None):
"""Builds a python project's dependencies into an artifact directory.

:type artifacts_dir_path: str
:param artifacts_dir_path: Directory to write dependencies into.

:type scratch_dir_path: str
:param scratch_dir_path: Directory to write temp files into.

:type requirements_path: str
:param requirements_path: Path to a requirements.txt file to inspect
for a list of dependencies.
Expand Down Expand Up @@ -114,7 +117,7 @@ def build_dependencies(self, artifacts_dir_path, requirements_path,
raise RequirementsFileNotFoundError(requirements_path)

self._dependency_builder.build_site_packages(
requirements_path, artifacts_dir_path)
requirements_path, artifacts_dir_path, scratch_dir_path)


class DependencyBuilder(object):
Expand Down Expand Up @@ -151,7 +154,9 @@ def __init__(self, osutils, pip_runner=None):
pip_runner = PipRunner(SubprocessPip(osutils))
self._pip = pip_runner

def build_site_packages(self, requirements_filepath, target_directory):
def build_site_packages(self, requirements_filepath,
target_directory,
scratch_directory):
"""Build site-packages directory for a set of requiremetns.

:type requirements_filepath: str
Expand All @@ -165,15 +170,17 @@ def build_site_packages(self, requirements_filepath, target_directory):
This directory should be on the PYTHON_PATH of whichever process
wants to use thse dependencies.

:type scratch_directory: str
:param scratch_directory: The directory to write temp files into.

:raises MissingDependencyError: This exception is raised if one or more
packages could not be installed. The complete list of missing
packages is included in the error object's ``missing`` property.
"""
if self._has_at_least_one_package(requirements_filepath):
with self._osutils.tempdir() as tempdir:
wheels, packages_without_wheels = self._download_dependencies(
tempdir, requirements_filepath)
self._install_wheels(tempdir, target_directory, wheels)
wheels, packages_without_wheels = self._download_dependencies(
scratch_directory, requirements_filepath)
self._install_wheels(scratch_directory, target_directory, wheels)
if packages_without_wheels:
raise MissingDependencyError(packages_without_wheels)

Expand Down
1 change: 0 additions & 1 deletion aws_lambda_builders/workflows/python_pip/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import tempfile
import shutil
import tarfile
import sys
import subprocess


Expand Down
3 changes: 2 additions & 1 deletion aws_lambda_builders/workflows/python_pip/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self,
**kwargs)

self.actions = [
PythonPipBuildAction(artifacts_dir, manifest_path, runtime),
PythonPipBuildAction(artifacts_dir, scratch_dir,
manifest_path, runtime),
CopySourceAction(source_dir, artifacts_dir),
]
Loading