prehistoric-motorcycle-70707
01/08/2023, 4:50 AMcryptography
library, and as I understand it, AWS Lambdas require a specific binary for that (and probably other) libraries. I was able to resolve that pre-Pants by following the instructions on this Github issue, but Im struggling to figure out how to get that working with the python_awslambda
target in Pants.
Pre-Pants I can run this pip command to fetch the correct binary pip install --platform manylinux2014_x86_64 --implementation cp --python 3.9 --only-binary=:all: --upgrade --target ./ cryptography==38.0.1
. But I dont understand how to translate this information to Pants and Pex. Im doing my best to understand, but pretty much everything Im doing is a stab in the dark 😂
I assume I need to do something with the complete_platforms
argument in the python_awslambda
target. So I created a file
target to a lambda_platform.json
file, and provided that to the complete_platform
argument. The json looks like this:
{
"marker_environment": {
"platform_release": "manylinux2014_x86_64",
"implementation_name": "cp",
"python_version": "3.9"
},
"compatible_tags": [
"cp39-abi3-manylinux2014_x86_64"
]
}
The package goal prints the correct platform file, however if I look at the cryptography dist info in the generated lambda, the WHEEL
file differs from what is generated when I run the pip command, and it doesnt seem to include the manylinux2014_x86_64
platform. So it doesnt appear to have worked.
Does anyone have any advice or thoughts here? Am I on the right track?
(Side note, changing the lambda_platform.json contents doesnt trigger a new package. I would've thought Pants would re-build if that dependency changed)prehistoric-motorcycle-70707
01/08/2023, 4:52 AMbroad-processor-92400
01/08/2023, 6:07 AMcryptography
, and it works fine for us on macOS and Linux. We use a complete platform file that's generated by running the appropriate pex command within the lambda environment itself, which ends up including many more elements in compatible_tags
, presumably all tags that are compatible (as well as different marker_environment
values).
Specifically, we set up a lambda containing the following, invoked it manually, and then copying the output into the .json
file:
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': "{}",
}
broad-processor-92400
01/08/2023, 6:10 AMbroad-processor-92400
01/08/2023, 6:11 AMprehistoric-motorcycle-70707
01/08/2023, 7:38 AMprehistoric-motorcycle-70707
01/08/2023, 7:40 AMprehistoric-motorcycle-70707
01/08/2023, 8:12 AMbroad-processor-92400
01/08/2023, 10:32 AMprehistoric-motorcycle-70707
01/08/2023, 3:49 PMbroad-processor-92400
01/08/2023, 10:32 PMfew-rocket-4266
06/02/2023, 6:04 AM