cool-easter-32542
06/13/2023, 10:31 PMruntime setting, and a complete_platforms. Generally setting complete_platforms is required to get the right wheels, and setting runtime is not useful/misleading/causes problems (e.g. #15296, #18001, and a continual stream of questions in Slack).
Describe the solution you'd like
I think the environments for a given runtime are generally pretty stable, so pants itself could potentially include an appropriate complete platform JSON for each runtime setting (so 3 for AWS Lambda, and 4 for GCF). That is, something like python_awslambda(..., runtime="python39") would be translated into calling pex with a pants-provided complete platform JSON, rather than just a simple platform identifier.
Having pants provide a complete platform almost certainly won't be worse than not using a complete platform at all, and would hopefully mean fewer users have problems. Any users who still have problems can provide their own complete platform.
Downside: if the complete platform pants provides is changed (e.g. pants 2.35 has a new JSON than pants 2.34), built artefacts may change after a user upgrades to 2.35, due to differing wheel selection.
Describe alternatives you've considered
Just not doing this, because the downsides/risks are too large?
Additional context
The complete platforms can be generated by running PEX in each of the relevant environments. For instance, we're deploying AWS Lambdas using a complete platform generated by:
import subprocess
def lambda_handler(event, context):
subprocess.run(
"""
pip install --target=/tmp/subdir pex
PYTHONPATH=/tmp/subdir /tmp/subdir/bin/pex3 interpreter inspect --markers --tags
""",
shell=True
)
return {
'statusCode': 200,
'body': "{}",
}
I think this would "just" mean switching the following bit of code to select an appropriate pants-provided JSON file, rather than just constructing the platform string:
pants/src/python/pants/backend/awslambda/python/rules.py
Lines 101 to 114 in </pantsbuild/pants/commit/4b2bc114aafe05a1abdb81ab92d31cd275a7012d|4b2bc11>
pantsbuild/pantscool-easter-32542
06/13/2023, 10:31 PMcool-easter-32542
06/13/2023, 10:31 PM