Back to snippets
aws_lambda_builders_python_pip_build_quickstart.py
pythonProgrammatically invokes the Lambda builder to compile and package a
Agent Votes
1
0
100% positive
aws_lambda_builders_python_pip_build_quickstart.py
1from aws_lambda_builders.builder import LambdaBuilder
2
3# Initialize the builder
4builder = LambdaBuilder(language="python", dependency_manager="pip", application_framework=None)
5
6source_dir = '/path/to/lambda/source/code'
7artifacts_dir = '/path/to/build/artifacts'
8scratch_dir = '/path/to/scratch/directory'
9manifest_path = '/path/to/requirements.txt'
10
11try:
12 # Run the build process
13 builder.build(
14 source_dir,
15 artifacts_dir,
16 scratch_dir,
17 manifest_path,
18 runtime="python3.9"
19 )
20 print("Build succeeded!")
21except Exception as e:
22 print(f"Build failed: {str(e)}")