silly-librarian-9816
03/03/2025, 3:30 PMservices/service1
āāā BUILD
āāā lib
ā āāā BUILD
ā āāā foo.py
ā āāā shared
ā āāā file1.py
ā āāā file2.py
āāā src
āāā lambda1
āāā BUILD
āāā main.py
lambda1/BUILD
python_sources(
name="lib",
sources=["**/*.py"],
)
python_aws_lambda_function(
name="lambda",
runtime="python3.12",
handler="main:handler",
dependencies=[
":lib",
"services/doc_gen/lib:lib",
],
)
lib/BUILD
python_sources(name="lib", sources=["**/*.py"])
The Issue
When I build the lambda, the directory structure inside the shared folder is flattened. Both foo.py and file1.py end up in the root of the lambda zip, losing the shared/ directory structure.
Interestingly, if I add additional subdirectories within shared/, those subdirectories are preserved correctly.
My Configuration
My pants.toml has:
[source]
root_patterns = [
"services/service1/src/**",
"services/service1/lib",
]
I'm wondering if there's something I'm missing about how Pants packages Python code when building lambdas.
Thanks in advance for any pointers!silly-librarian-9816
03/03/2025, 3:56 PM"lib/**" and didn't realize it needed to be "/lib/**"happy-kitchen-89482
03/05/2025, 5:49 AM