https://pantsbuild.org/ logo
#general
Title
# general
b

brash-student-40401

01/11/2023, 5:55 PM
Having a strange problem building a distribution for a Lambda function where the function is dying because the PEX doesn't have required dependencies. Here's my `BUILD`:
Copy code
docker_image(
    name="create_json_image",
    repository="repo",
    dependencies=[":create_json_lambda"],
    image_tags=["tag"],
)

python_awslambda(
    name="create_json_lambda",
    runtime="python3.8",
    handler="lambda_function.py:lambda_handler",
)

python_sources(
    dependencies=[
        "src/vendor/python:reqs#pkg1",
        "src/vendor/python:reqs#pkg2",
    ]
)
And then the Lambda itself gives me errors like:
Copy code
[ERROR] ResolveError: Failed to resolve requirements from PEX environment @ /app.
Needed cp38-cp38-manylinux_2_26_x86_64 compatible dependencies for:
1: Pillow>=8.1.1
Required by:
pkg2
But this pex had no ProjectName(raw='Pillow', normalized='pillow') distributions.
(with lots of other un-available packages). Is this a problem with Lambdex? Pants has always been so great at avoiding dependency errors!
b

broad-processor-92400

01/11/2023, 8:29 PM
The selection of wheels will be best if you use a complete platform JSON file for the environment you’re deploying to, instead of the
runtime
that just estimates what will be compatible, and may choose wheels that are too new/incompatible. Once you use a JSON file, you may also need to tell pants about the latest version of the PEX tool, as it contains some relevant bug fixes. Here’s a thread from a few days ago that discusses these: https://pantsbuild.slack.com/archives/C046T6T9U/p1673153412271249 (Note: that’s for 3.9, not 3.8, so the files there won’t be directly applicable)
Also, before diving into fixes based on incompatible wheels being chosen, you should probably look in the zip file and confirm that this is the cause. One symptom would be the Pillow wheel existing in the file with a
manylinux
tag greater than
2_26
, eg
Pillow-…manylinux_2_32….whl
👀 1
2 Views