I upgraded the python interpreter version from 3.9...
# general
a
I upgraded the python interpreter version from 3.9 to 3.12 for a project that has a few aws lambda functions and now I'm running into the following error when I try and package any handler that uses sqlalchemy:
Copy code
Failed to resolve requirements from PEX environment @ /tmp/pants-sandbox-xkca5Z/faas_repository.pex.
Needed cp312-cp312-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.52
    But this pex had no ProjectName(raw='greenlet', validated=False, normalized='greenlet') distributions.
The resolve's lock file shows greenlet 3.0.3 as a dependency and it supports python 3.12 so I'm not sure what's going on here. Any help would be appreciated.
b
You might need to constrain the version of
greenlet
further beyond just
!=0.4.17
- for what it’s worth, we have a tighter constraint in
pyproject.toml
of
greenlet = "^3.0.0"
. I vaguely remember running into a similar issue when upgrading to Python 3.12
a
Still erroring out, but now it's a different error:
Copy code
A distribution for greenlet could not be resolved for cp312-cp312-linux_x86_64.
Found 1 distribution for greenlet that do not apply:
1.) The wheel tags for greenlet 3.0.3 are cp312-cp312-manylinux_2_24_x86_64, cp312-cp312-manylinux_2_28_x86_64 which do not match the supported tags of cp312-cp312-linux_x86_64:
cp312-cp312-manylinux2014_x86_64
... 122 more ...
I tried some of the debug flags to see if I could expand out that "122 more" but I couldn't. I'm not too familiar with the whole wheel process but I feel like the manylinux distributions should match?
b
Sorry for the trouble! What version of Pants?
Ah, actually, that's irrelevant. This is likely to be an issue due to Pants not (yet) packaging a "complete platforms" file for the Python 3.12 lambda environment. https://github.com/pantsbuild/pants/discussions/18756 describes one approach to generating one... but you could also copy the one I just generated for landing in a future version of Pants: https://github.com/pantsbuild/pants/pull/21004/files#diff-c32954f1a6847c2b63623fd4cfa1a715a44c6be5edb845e43e989daede410532 You'll need to put that in a
file
target and then reference in the
complete_platforms=["path/to:target"]
on the Lambda target(s).
👀 1
a
That worked! Thank you!
👍 1
b
yay, glad it helped. Sorry for the trouble. Thanks for asking too, btw, two useful things come out of it for the community: • that 21004 PR, which will hopefully land soon and thus come out in a future release making it easier for everyone to use Python 3.12 in Lambda • https://github.com/pantsbuild/pants/issues/21005 which stop the silent fallback to often-wrong behaviour and provide specific guidance
🎉 1