Hi, I'm trying to bundle my app with `python_awsl...
# general
w
Hi, I'm trying to bundle my app with
python_awslambda
, in a similar fashion as a
pex_binary
:
Copy code
pex_binary(
    name="performance_profile",
    entry_point="performance_profile.py",
    interpreter_constraints=["==3.11.*"],
    dependencies=[":src"],
)

python_awslambda(
    name="lambda_performance_profile",
    runtime="python3.11",
    handler="lambda_function.py:performance_profile_handler",
    dependencies=[":src"],
)
I can create and run the pex file, but I am struggling with this error for the second use case :
Copy code
stderr:
Failed to resolve requirements from PEX environment @ /home/..
Needed cp311-cp311-linux_x86_64 compatible dependencies for:
 1: pillow>=6.2.0
    Required by:
      matplotlib 3.8.0
    But this pex had no ProjectName(raw='pillow', normalized='pillow') distributions.
which I tried to solve by explicitly adding
pillow
to the dependencies. But then I encounter an other error :
Copy code
stderr:
A distribution for pillow could not be resolved for cp311-cp311-linux_x86_64.
Found 1 distribution for pillow that do not apply:
1.) The wheel tags for Pillow 9.5.0 are cp311-cp311-manylinux_2_28_x86_64 which do not match the supported tags of cp311-cp311-linux_x86_64:
cp311-cp311-manylinux2014_x86_64
... 113 more ...
that is, I'm afraid, as far as I could get. How come the supported tag does not mention
manylinux
? how does the dependency resolver differ between
python_awslambda
and
pex_binary
?
b
Sorry for the trouble. What version of pants? Are those errors when you build the lambda or when you run it in AWS?
w
I'm using Pants 2.17.0, this error arises when building with
pants package
I'm also specifying :
Copy code
[lambdex]
layout = "zip"
in
pants.toml
b
Ah okay. You may need to switch to providing a
complete_platforms
parameter to the target to accurately convey which wheels need to be selected. In https://github.com/pantsbuild/pants/discussions/18756 I describe more about how/why to do this. You can take the file from https://github.com/pantsbuild/pants/blob/main/src/python/pants/backend/awslambda/python/complete_platform_3.11-x86_64.json (Pants 2.18 has an extra feature to automatically provide an appropriate file)
w
sounds promising, thanks ! I’ll try my luck first thing tomorrow
e
It's the same resolver. The difference is the
pex_binary
is built for a local interpreter but the
python_awslambda
is built for a foreign interpreter (the one the AWS Lamba runtime provides). What Pants version is this? The answer is complete_platforms, but how you set that up depends on the Pants version.
b
it's 2.17
e
Hrm, weird. I now see a bunch of conversation above my response that I did not see before. Sorry for the noise!