Hi, I tried using pants 2.17.0 to package docker i...
# general
h
Hi, I tried using pants 2.17.0 to package docker images. With 2.16.0 I had no errors but now:
Copy code
Failed to resolve requirements from PEX environment @ /tmp/pantsbuild/named_caches/pex_root/unzipped_pexes/6b15572581a6e7fb7c6a3c1893a4b2cccdc89e28.
Needed cp38-cp38-linux_x86_64 compatible dependencies for:
 1: greenlet!=0.4.17; python_version >= "3" and (platform_machine == "aarch64" or (platform_machine == "ppc64le" or (platform_machine == "x86_64" or (platform_machine == "amd64" or (platform_machine == "AMD64" or (platform_machine == "win32" or platform_machine == "WIN32"))))))
    Required by:
      SQLAlchemy 1.4.37
    But this pex had no ProjectName(raw='greenlet', normalized='greenlet') distributions.
I am using a docker_environment and the new layout="zip" feature:
Copy code
docker_environment(
    name="local_qgis",
    image="opengisch/qgis@sha256:9c02323a70a3cddea4f73ff94ded5cdae7d6cc128d0a140aee8128383f0815b4",
)
I found this issue https://github.com/pantsbuild/pants/issues/18936 and one comment said this error will be fixed in 2.17.0.
b
Sorry for the trouble! Hm, just clarifying to make sure we're helping about the right thing:
[lambdex] layout = "zip"
applies to
python_awslambda
targets, but you mention you're packaging docker images, so I'm slightly wary of things being mixed up. Could you confirm you see this error when running
pants package path/to:target
where that target in
path/to/BUILD
is a
docker_image
? Could you you could share the specific BUILD target definitions? Potentially some more logging context would be good too, e.g. there might be an
[ERROR] ...
line that would be good to see.
h
Hi, I'll prepare that for you 🙂
I forgot the first line of error message. To clarify I'm building a docker image that uses a python_awslambda target. I think the problem lies in the lambda target:
ProcessExecutionFailure: Process 'Build python_awslambda artifact for services/qgis_file:qgis-lambda' failed with exit code 1.
It works with these settings:
Copy code
python_awslambda(
    name="qgis-lambda",
    runtime="python3.8",
    handler="lambda_handler.py:handler",
    dependencies=[":glt"]
)
python_requirement(
    name="glt",
    requirements=["greenlet==1.1.1"],
)
Before I had greenlet 3.0.0 installed which was not recognized. After including it explicitly as an dependency in python_awslambda target I got:
Copy code
ProcessExecutionFailure: Process 'Build python_awslambda artifact for services/qgis_file:qgis-lambda' failed with exit code 1.
stdout:

stderr:
A distribution for greenlet could not be resolved for cp38-cp38-linux_x86_64.
Found 1 distribution for greenlet that do not apply:
1.) The wheel tags for greenlet 3.0.0 are cp38-cp38-manylinux_2_24_x86_64, cp38-cp38-manylinux_2_28_x86_64 which do not match the supported tags of cp38-cp38-linux_x86_64:
cp38-cp38-manylinux2014_x86_64
... 86 more ...
Then I just guessed another version like 1.1.1 and it worked. The error only occurs in pants 2.17.0. Is there a better way to find out what version of greenlet is for cp38-cp38-linux_x86_64.? I just tried some but that's not a good workflow.
I think I'll try to set the complete platforms field instead of the runtime filed: https://www.pantsbuild.org/docs/reference-python_awslambda#coderuntimecode
For another service I am getting this error (same awslambda target parameters like above):
Copy code
12:07:57.31 [ERROR] 1 Exception encountered:

Engine traceback:
  in `publish` goal

ProcessExecutionFailure: Process 'Build python_awslambda artifact for services/qgis-error:qgis-error-lambda' failed with exit code 1.
stdout:

stderr:
A distribution for langchain could not be resolved for cp38-cp38-linux_x86_64.
Found 1 distribution for langchain that do not apply:
1.) The distribution has a python requirement of <4.0,>=3.8.1 which does not match the python version of 3.8 for cp38-cp38-linux_x86_64.



Use `--keep-sandboxes=on_failure` to preserve the process chroot for inspection.
e
@happy-family-315 for this last one,
langchain
requires
Python>=3.8.1,<4
but you're using a platform that just says 3.8, which includes / implies 3.8.0. And 3.8.0 does not meet the criteria langchain has; so the failure makes complete sense. Your new direction of using
complete_platforms
is a correct one. Presumably the AWS Lambda 3.8 runtime / image you'll generate the complete platform from uses a newer CPython than 3.8.1.
h
@enough-analyst-54434 thank you very much! Do you know how I can get the values for complete_platforms? I set runtime to 3.8 because there is just a python 3.8 lambda image. How can I get the platform values for this specific image?