Hey there dear people! I am having a strange issue...
# general
p
Hey there dear people! I am having a strange issue when using pants in CD to build lambda functions. If I run on my local machine:
pants package path/to/lambda/:lambda
it works and I get a deployable .zip file, but if I run the same in CD I get:
Copy code
ProcessExecutionFailure: Process 'Build python_awslambda artifact for path/to/lambda/:lambda' failed with exit code 1.
stdout:

stderr:
A distribution for pillow could not be resolved for cp310-cp310-linux_x86_64.
Found 1 distribution for pillow that do not apply:
1.) The wheel tags for Pillow 10.0.1 are cp310-cp310-manylinux_2_28_x86_64 which do not match the supported tags of cp310-cp310-linux_x86_64:
cp310-cp310-manylinux2014_x86_64
I am running the same version of python on the GHA and in my local machine I believe, (3.10.13), so no idea why this wouldn't work - any idea how to solve it? appreciate a lot any guidance! 🙏
When I generate the lockfile I get the following pillow wheels:
Copy code
{
  "algorithm": "sha256",
  "hash": "f6d3d4c905e26354e8f9d82548475c46d8e0889538cb0657aa9c6f0872a37aa4",
  "url": "<https://files.pythonhosted.org/packages/9b/ba/391fd1ff93e158cb34de3d2e003c070ee85b8840a4fe99a900463d75efad/Pillow-10.0.1-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl>"
},
{
  "algorithm": "sha256",
  "hash": "32bec7423cdf25c9038fef614a853c9d25c07590e1a870ed471f47fb80b244db",
  "url": "<https://files.pythonhosted.org/packages/2c/30/458e634572b833d8208ee83ca4e43bb6c21ccdd1b6149f4baf072f8807e8/Pillow-10.0.1-pp310-pypy310_pp73-macosx_10_10_x86_64.whl>"
},
{
  "algorithm": "sha256",
  "hash": "f11c9102c56ffb9ca87134bd025a43d2aba3f1155f508eff88f694b33a9c6d19",
  "url": "<https://files.pythonhosted.org/packages/52/97/9fb1b66fbf98893722247fdf6ac39467a7b177483b546a94dbcff66653f0/Pillow-10.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl>"
},
{
  "algorithm": "sha256",
  "hash": "e6a90167bcca1216606223a05e2cf991bb25b14695c518bc65639463d7db722d",
  "url": "<https://files.pythonhosted.org/packages/53/ac/3f9450af6583199b1c408f3a9a0f65e6dedc25aed15f691a74bcfa2d1077/Pillow-10.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl>"
},
{
  "algorithm": "sha256",
  "hash": "50bd5f1ebafe9362ad622072a1d2f5850ecfa44303531ff14353a4059113b12d",
  "url": "<https://files.pythonhosted.org/packages/55/93/9a8b06ca5917f246d1cd31351d5ec38651f8f5f9619c8db5751583f49ba3/Pillow-10.0.1-cp310-cp310-macosx_11_0_arm64.whl>"
},
{
  "algorithm": "sha256",
  "hash": "d72967b06be9300fed5cfbc8b5bafceec48bf7cdc7dab66b1d2549035287191d",
  "url": "<https://files.pythonhosted.org/packages/64/9e/7e638579cce7dc346632f020914141a164a872be813481f058883ee8d421/Pillow-10.0.1.tar.gz>"
},
{
  "algorithm": "sha256",
  "hash": "0462b1496505a3462d0f35dc1c4d7b54069747d65d00ef48e736acda2c8cbdff",
  "url": "<https://files.pythonhosted.org/packages/7a/07/e896b096a77375e78e02ce222ae4fd6014928cd76c691d312060a1645dfa/Pillow-10.0.1-cp310-cp310-manylinux_2_28_x86_64.whl>"
},
{
  "algorithm": "sha256",
  "hash": "8f06be50669087250f319b706decf69ca71fdecd829091a37cc89398ca4dc17a",
  "url": "<https://files.pythonhosted.org/packages/8c/34/4e02804420b1cd9371ce5f7c0da7024a8450e6b092c336d3233d6c6448d9/Pillow-10.0.1-cp310-cp310-macosx_10_10_x86_64.whl>"
},
{
  "algorithm": "sha256",
  "hash": "552912dbca585b74d75279a7570dd29fa43b6d93594abb494ebb31ac19ace6bd",
  "url": "<https://files.pythonhosted.org/packages/9e/33/0140c7dbe509d4e765558c976bea108fd2f63d527a9e16860392ccbcae72/Pillow-10.0.1-cp310-cp310-musllinux_1_1_x86_64.whl>"
},
{
  "algorithm": "sha256",
  "hash": "186f7e04248103482ea6354af6d5bcedb62941ee08f7f788a1c7707bc720c66f",
  "url": "<https://files.pythonhosted.org/packages/a1/a7/35db8e4d15e8f139f9eda3378260a91b2ef7342342769dbeaff8dbc29c26/Pillow-10.0.1-cp310-cp310-manylinux_2_28_aarch64.whl>"
},
{
  "algorithm": "sha256",
  "hash": "b7cf63d2c6928b51d35dfdbda6f2c1fddbe51a6bc4a9d4ee6ea0e11670dd981e",
  "url": "<https://files.pythonhosted.org/packages/af/66/d2aaf99819c7aef39f65b43c67ef968128aff33d44c230ec675b40a7ffb4/Pillow-10.0.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl>"
},
{
  "algorithm": "sha256",
  "hash": "d889b53ae2f030f756e61a7bff13684dcd77e9af8b10c6048fb2c559d6ed6eaf",
  "url": "<https://files.pythonhosted.org/packages/d2/4f/9bb94120b219e050588684cc5f4d1d48d97e0e4a1ec6c1aa68369132d2c7/Pillow-10.0.1-cp310-cp310-musllinux_1_1_aarch64.whl>"
}
And if I re-generate the lockfile in the GHA runner, I get the same This is quite strange, I wonder why is the package command looking for
cp310-cp310-linux_x86_64
? and how to fix this?
b
Sorry for the trouble! What’s your lambda target definition? What platform is your local machine?
p
thanks a lot for the answer! 🙂 my target definition is:
Copy code
python_awslambda(
    name="lambda",
    runtime="python3.10",
    handler="app.py:lambda_handler",
)
and my local machine is a dev container with ubuntu linux 22.04, exactly the same as the gha runner
👍 1
b
Hm, definitely unexpected to me that there’s a difference between two almost identical platforms? Maybe the installed version of glibc is slightly different? (I don’t know how to check, though) To clarify, do you mean the CI and your local are on the same version of Ubuntu, or, using truly identical docker images? The “real” fix is to use a complete platform, which has to be done manually in Pants 2.17 and earlier, but is coming built in in 2.18. https://github.com/pantsbuild/pants/discussions/18756 describes what we do.
🙏 1
❤️ 1
p
It's strange indeed! we're using the same version of ubuntu linux, not the same docker image (good point)
What's described in the issue seems honestly very complex just to build a lambda .zip 😕 when is the 2.18 release planned for?
Also gclib is the same in the gha runner and in the dev container
c
The most recent version is 2.18.0rc1: https://pantsbuild.slack.com/archives/C18RRR4JK/p1695595887031759 Follow #C18RRR4JK to get notified of new releases. We aim for another rc release every ~1 weeks or so until there are no more bugfixes after which the final stable version will be released. So when the stable lands is a bit hard to predict 😬 More details here https://www.pantsbuild.org/docs/release-strategy
🙏 1
❤️ 1
p
Alright sounds good! Thanks so much! 🙂
Btw I have managed to get a temp fix for the issue above by replacing in CD in the
python_default.lock
the wheel that pants is expecting to find
Copy code
- name: Fix wheels in runner
  run: |
    # issue with Pants 2.17, will be fixed in 2.18 - this temporarly fixes it
    # fix for pillow~=10.0.0
    sed -i "s/cp310-cp310-manylinux_2_28_x86_64/cp310-cp310-manylinux2014_x86_64/g" python_default.lock
With this the package command works, and I can deploy the lambda
e
@proud-byte-81916 boo! The amount of effort to set up a complete platform JSON file and use it - 5 minutes - is easily within the bounds of the time spent here by all involved. If you do that, you get the 2.18 treatment now and you can actually have confidence you know what you're doing. With the cowboyed lock you're on your own (which isn't true, you'll ask about the issues it gives you here and, hopefully, remember to tell folks about the cowboy when they're trying to help you diagnose).
p
Thanks for the feedback dear John! Perhaps I over-estimated the time to have the json solution running from just reading the issue, I will try it out 🙂
e
Great - excellent.
Hm, definitely unexpected to me that there’s a difference between two almost identical platforms?
There may not be, but the issue is the abbreviated platform used by default for python_awslambda does not have enough information to re-construct a either a full proper marker environment or a full proper tag set. It forces the tag set to be derived by calling Pip like so:
Copy code
$ pip debug --verbose --platform linux_x86-64 --platform manylinux2014_x86_64 --implementation cp --python-version 3.10 --abi cp310 | grep -A105 "Compatible tags"
WARNING: This command is only meant for debugging. Do not use this with automation for parsing and getting these details, since the output and options of this command may change without notice.
Compatible tags: 105 (target: platforms=['linux_x86-64', 'manylinux2014_x86_64'] version_info='3.10' abis=['cp310'] implementation='cp')
  cp310-cp310-linux_x86-64
  cp310-cp310-manylinux2014_x86_64
  cp310-cp310-manylinux2010_x86_64
  cp310-cp310-manylinux1_x86_64
  cp310-abi3-linux_x86-64
  cp310-abi3-manylinux2014_x86_64
  cp310-abi3-manylinux2010_x86_64
  cp310-abi3-manylinux1_x86_64
  cp310-none-linux_x86-64
  cp310-none-manylinux2014_x86_64
  cp310-none-manylinux2010_x86_64
  cp310-none-manylinux1_x86_64
  cp39-abi3-linux_x86-64
  cp39-abi3-manylinux2014_x86_64
  ... <snipped> ...
  py30-none-any
Maybe the installed version of glibc is slightly different? (I don’t know how to check, though)
A quick way to check glibc version:
Copy code
$ ldd --version
ldd (Ubuntu GLIBC 2.35-0ubuntu3.3) 2.35
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
So glibc is 2.35 there.
👍 1
If I haven't made it clear, I'll re-emphasize that
platforms
(abbreviated platforms - what the
python_awslambda
target is using in this problem case) - were introduced as a Twitter hack that worked in their limited / controlled environment, but do not work in general except by getting a bit lucky. Pants should eventually definitely deprecate them - a complete platform is always better and always correct. The abbreviated platform is often plain old incorrect. I've done my best to make them as robust as possible after taking over stewardship by failing fast for un-knowable environment markers, but they do not fail fast for un-knowable tags.
❤️ 1
🙏 1
p
Thanks so much John!
b
(If you haven't computed one yourself already, you can take the complete platform that pants will be providing: https://github.com/pantsbuild/pants/blob/725d7ec4e08543c0bd6e3ae504ba9c87f3a42040/[…]nts/backend/awslambda/python/complete_platform_3.10-x86_64.json )
❤️ 1
p
That's amazing thanks so much! Will try this tomorrow and keep you posted
@enough-analyst-54434 @broad-processor-92400 I have added the 3rdparty/platforms BUILD file with the json linked above for lambda with python3.10, then I added to the BUILD file of the lambda the
complete_platforms
directive, so my build file in the lambda function project now looks like:
Copy code
python_sources(
    name="ner_logo_gen",
    sources=["**/*.py"],
    dependencies=[":env_file"],
)

python_tests(
    name="tests",
    sources=["tests/**/test_*.py"],
    dependencies=[":tests_support_files", ":env_file"],
)

resources(
    name="tests_support_files",
    sources=["tests/**/*"],
)

resources(name="env_file", sources=[".env", ".env.template"])

python_awslambda(
    name="lambda",
    runtime="python3.10",
    handler="app.py:lambda_handler",
    complete_platforms=["3rdparty/platforms:aws_lambda_python_3_10"]
)
Now when I run package, I get this new error though:
Copy code
13:44:15.93 [INFO] Completed: Build python_awslambda artifact for kittl/projects/ner_logo_gen:lambda
13:44:15.93 [ERROR] 1 Exception encountered:

Engine traceback:
  in `package` goal

ProcessExecutionFailure: Process 'Build python_awslambda artifact for kittl/projects/ner_logo_gen:lambda' failed with exit code 1.
stdout:

stderr:
A single target is required for creating a flat sys.path directory entry.
There were 2 targets selected:
1. cp310-cp310-linux_x86_64
2. cp310-cp310-manylinux_2_26_x86_64
Any idea as how to possibly fix this? Thanks so much really appreciate! 🙏
e
You must delete the
python_awslambda
target
runtime
field.
❤️ 1
p
Sounds great, trying it right now
It works! Thanks so much for the help I really appreciate it! 🙏 And thanks a lot for pointing out yesterday that this solution was easy, it was indeed