diff --git a/aws_lambda_builders/__main__.py b/aws_lambda_builders/__main__.py index b4fc80cfa..d29839893 100644 --- a/aws_lambda_builders/__main__.py +++ b/aws_lambda_builders/__main__.py @@ -124,6 +124,8 @@ def main(): # pylint: disable=too-many-statements optimizations=params["optimizations"], options=params["options"], mode=params.get("mode", None), + download_dependencies=params.get("download_dependencies", True), + dependencies_dir=params.get("dependencies_dir", None), ) # Return a success response diff --git a/aws_lambda_builders/builder.py b/aws_lambda_builders/builder.py index 9a9a3d04d..f11187f2b 100644 --- a/aws_lambda_builders/builder.py +++ b/aws_lambda_builders/builder.py @@ -64,6 +64,8 @@ def build( options=None, executable_search_paths=None, mode=None, + download_dependencies=True, + dependencies_dir=None, ): """ Actually build the code by running workflows @@ -105,6 +107,14 @@ def build( :type mode: str :param mode: Optional, Mode the build should produce + + :type mode: bool + :param download_dependencies: + Optional, Should download dependencies when building + + :type mode: str + :param dependencies_dir: + Optional, Path to folder the dependencies should be downloaded to """ if not os.path.exists(scratch_dir): @@ -120,6 +130,8 @@ def build( options=options, executable_search_paths=executable_search_paths, mode=mode, + download_dependencies=download_dependencies, + dependencies_dir=dependencies_dir, ) return workflow.run() diff --git a/aws_lambda_builders/workflow.py b/aws_lambda_builders/workflow.py index 42263085b..83e9aa765 100644 --- a/aws_lambda_builders/workflow.py +++ b/aws_lambda_builders/workflow.py @@ -140,6 +140,8 @@ def __init__( optimizations=None, options=None, mode=BuildMode.RELEASE, + download_dependencies=True, + dependencies_dir=None, ): """ Initialize the builder with given arguments. These arguments together form the "public API" that each @@ -182,6 +184,14 @@ def __init__( :type mode: str :param mode: Optional, Mode the build should produce + + :type mode: bool + :param download_dependencies: + Optional, Should download dependencies when building + + :type mode: str + :param dependencies_dir: + Optional, Path to folder the dependencies should be downloaded to """ self.source_dir = source_dir @@ -193,6 +203,8 @@ def __init__( self.options = options self.executable_search_paths = executable_search_paths self.mode = mode + self.download_dependencies = download_dependencies + self.dependencies_dir = dependencies_dir # Actions are registered by the subclasses as they seem fit self.actions = [] diff --git a/tests/functional/test_cli.py b/tests/functional/test_cli.py index e937cf23a..6f2b4fe5b 100644 --- a/tests/functional/test_cli.py +++ b/tests/functional/test_cli.py @@ -77,6 +77,8 @@ def test_run_hello_workflow_with_backcompat(self, flavor, protocol_version): "runtime": "ignored", "optimizations": {}, "options": {}, + "download_dependencies": False, + "dependencies_dir": "/ignored-dep", }, } @@ -138,6 +140,8 @@ def test_run_hello_workflow_incompatible(self, flavor): "optimizations": {}, "options": {}, "executable_search_paths": [str(pathlib.Path(sys.executable).parent)], + "download_dependencies": False, + "dependencies_dir": "/ignored-dep", }, } ) diff --git a/tests/unit/test_builder.py b/tests/unit/test_builder.py index 08148158c..2c040b7f3 100644 --- a/tests/unit/test_builder.py +++ b/tests/unit/test_builder.py @@ -82,6 +82,8 @@ def __init__( options=None, executable_search_paths=None, mode=None, + download_dependencies=True, + dependencies_dir=None, ): super(MyWorkflow, self).__init__( source_dir, @@ -93,6 +95,8 @@ def __init__( options=options, executable_search_paths=executable_search_paths, mode=mode, + download_dependencies=download_dependencies, + dependencies_dir=dependencies_dir, ) # Don't load any other workflows. The above class declaration will automatically load the workflow into registry @@ -136,6 +140,8 @@ def test_with_mocks(self, scratch_dir_exists, get_workflow_mock, importlib_mock, options="options", executable_search_paths="executable_search_paths", mode=None, + download_dependencies=False, + dependencies_dir="dependency_folder", ) workflow_cls.assert_called_with( @@ -148,6 +154,8 @@ def test_with_mocks(self, scratch_dir_exists, get_workflow_mock, importlib_mock, options="options", executable_search_paths="executable_search_paths", mode=None, + download_dependencies=False, + dependencies_dir="dependency_folder", ) workflow_instance.run.assert_called_once() os_mock.path.exists.assert_called_once_with("scratch_dir")