Hi folks :wave: I've been troubleshooting a Pants ...
# general
s
Hi folks šŸ‘‹ I've been troubleshooting a Pants issue for a few hours and could use some help. I suspect I'm making a simple configuration mistake. My project structure:
Copy code
services/service1
ā”œā”€ā”€ BUILD
ā”œā”€ā”€ lib
│   ā”œā”€ā”€ BUILD
│   ā”œā”€ā”€ foo.py
│   └── shared
│       ā”œā”€ā”€ file1.py
│       ā”œā”€ā”€ file2.py
└── src
     └── lambda1
            ā”œā”€ā”€ BUILD
            └── main.py
lambda1/BUILD
Copy code
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
Copy code
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:
Copy code
[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!
Ok, figured it out on my own. I also had a source root of
"lib/**"
and didn't realize it needed to be
"/lib/**"
h
Ah, great, was going to suggest looking at source roots šŸ™‚