You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aws_lambda_builders/workflows/python_pip/DESIGN.md
+44Lines changed: 44 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -147,3 +147,47 @@ bundle has an `__init__.py` and is on the `PYTHONPATH`.
147
147
The dependencies should now be succesfully installed in the target directory.
148
148
All the temporary/intermediate files can now be deleting including all the
149
149
wheel files and sdists.
150
+
151
+
### Configuring the builder
152
+
153
+
The Lambda builder supports the following optional sub-properties of the `aws_sam` configuration property.
154
+
155
+
#### `parent_python_packages`
156
+
157
+
`parent_python_packages` must be a string, corresponding to a dot-separated list of parent packages to create in the destination directory. This is useful when the source code has a package structure that needs to be preserved in the built artifacts.
158
+
159
+
For example, if your source code is structured like this:
160
+
161
+
```
162
+
├── app
163
+
| ├── main.py
164
+
| └── utils
165
+
| └── logger.py
166
+
└── tests
167
+
└── unit/test_handler.py
168
+
```
169
+
170
+
Then the SAM build output will look like this:
171
+
172
+
```
173
+
└── .aws-sam
174
+
└── build
175
+
└── AppLogicalId
176
+
├── main.py
177
+
└── utils
178
+
└── logger.py
179
+
```
180
+
181
+
The tests would break because `main.py` is importing `logger` as `from .utils import logger`, but the built artifacts would not have the `app` package.
182
+
183
+
To fix this, you can set the `parent_python_packages` property to `app` and the SAM build output will look like this:
0 commit comments