I am using python_awslambda according to the <docu...
# general
b
I am using python_awslambda according to the documentation by copying the zip to docker_image. As recommended, I set [python].enable_resolves = true and get a resolve error that I cannot resolve. Details of the error are in the thread.
Error is here. I have specified the json generated in the amazon linux environment in python_awslambda.complete_platforms based on the documentation.
Copy code
pex.environment.ResolveError: A distribution for pyyaml could not be resolved in this environment.Found 1 distribution for pyyaml that do not apply:
1.) The wheel tags for PyYAML 6.0 are cp38-cp38-manylinux_2_17_aarch64, cp38-cp38-manylinux2014_aarch64 which do not match the supported tags of /var/lang/bin/python3.8:
cp38-cp38-manylinux_2_26_x86_64
cp38-cp38-manylinux_2_25_x86_64
cp38-cp38-manylinux_2_24_x86_64
cp38-cp38-manylinux_2_23_x86_64
cp38-cp38-manylinux_2_22_x86_64
cp38-cp38-manylinux_2_21_x86_64
cp38-cp38-manylinux_2_20_x86_64
cp38-cp38-manylinux_2_19_x86_64
cp38-cp38-manylinux_2_18_x86_64
cp38-cp38-manylinux_2_17_x86_64
cp38-cp38-manylinux2014_x86_64
cp38-cp38-manylinux_2_16_x86_64
cp38-cp38-manylinux_2_15_x86_64
cp38-cp38-manylinux_2_14_x86_64
cp38-cp38-manylinux_2_13_x86_64
cp38-cp38-manylinux_2_12_x86_64
cp38-cp38-manylinux2010_x86_64
cp38-cp38-manylinux_2_11_x86_64
cp38-cp38-manylinux_2_10_x86_64
cp38-cp38-manylinux_2_9_x86_64
cp38-cp38-manylinux_2_8_x86_64
cp38-cp38-manylinux_2_7_x86_64
cp38-cp38-manylinux_2_6_x86_64
cp38-cp38-manylinux_2_5_x86_64
...
I’m a little concerned because when I look at the pypi in pyyaml, it looks like cp38-cp38-manylinux_2_5_x86_64. https://pypi.org/project/PyYAML/6.0/#files
default_lockfile.txt
Copy code
# This lockfile was autogenerated by Pants. To regenerate, run:
#
#    ./pants generate-lockfiles --resolve=python-default
#
# --- BEGIN PANTS LOCKFILE METADATA: DO NOT EDIT OR REMOVE ---
# {
#   "version": 2,
#   "valid_for_interpreter_constraints": [
#     "CPython==3.8.*"
#   ],
#   "generated_with_requirements": [
#     "PyYAML<7.0.0,>=6.0",
#     "SQLAlchemy-Utils<0.39.0,>=0.38.2",
#     "SQLAlchemy<2.0.0,>=1.4.32",
#     "absl-py<2.0.0,>=1.0.0",
#     "boto3-type-annotations<0.4.0,>=0.3.1",
#     "boto3<2.0.0,>=1.21.14",
#     "chalice<2.0.0,>=1.26.6",
#     "mysql-connector-python<9.0.0,>=8.0.28",
#     "numpy<2.0.0,>=1.22.1",
#     "protobuf==3.20.1",
#     "pytz<2022.0.0,>=2021.3"
#   ]
# }
# --- END PANTS LOCKFILE METADATA ---

absl-py==1.2.0; python_version >= "3.6"
ansicon==1.89.0; platform_system == "Windows" and python_version >= "3.7"
attrs==21.4.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
blessed==1.19.1; python_version >= "3.7"
boto3-type-annotations==0.3.1
boto3==1.24.32; python_version >= "3.7"
botocore==1.27.32; python_version >= "3.7"
chalice==1.27.1
click==8.1.3; python_version >= "3.7"
colorama==0.4.5; python_version >= "3.7" and python_full_version < "3.0.0" and platform_system == "Windows" or platform_system == "Windows" and python_version >= "3.7" and python_full_version >= "3.5.0"
greenlet==1.1.2; python_version >= "3" and python_full_version < "3.0.0" 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") and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0") and (python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.6.0") or 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") and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0") and (python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.6.0") and python_full_version >= "3.5.0"
inquirer==2.9.2; python_version >= "3.7"
jinxed==1.2.0; platform_system == "Windows" and python_version >= "3.7"
jmespath==1.0.1; python_version >= "3.7"
mypy-extensions==0.4.3
mysql-connector-python==8.0.29
numpy==1.23.1; python_version >= "3.8"
pip==22.1.2; python_version >= "3.7"
protobuf==3.20.1; python_version >= "3.7"
python-dateutil==2.8.2; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.7"
python-editor==1.0.4; python_version >= "3.7"
pytz==2021.3
pyyaml==6.0; python_version >= "3.6"
readchar==3.0.5; python_version >= "3.7"
s3transfer==0.6.0; python_version >= "3.7"
setuptools==63.2.0; python_version >= "3.7"
six==1.16.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.7"
sqlalchemy-utils==0.38.3; python_version >= "3.6" and python_version < "4.0"
sqlalchemy==1.4.39; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")
urllib3==1.26.10; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7"
wcwidth==0.2.5; python_version >= "3.7"
wheel==0.37.1; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
e
@bland-father-19717 you'll need to delete the
runtime
field in your
python_awslambda
target and instead define `complete_platforms`: https://www.pantsbuild.org/docs/reference-python_awslambda#codecomplete_platformscode That requires a bit of work to set up. 1st, in your docker container, temporarily install pex and create the complete platform json datafail as described here: https://pex.readthedocs.io/en/latest/buildingpex.html#complete-platform Roughly:
Copy code
docker run --rm -it my-image /bin/bash
$ /the/python/you/want/bin/python -mvev pex.venv
$ pex.venv/bin/pip install pex
$ pex.venv/bin/pex3 interpreter inspect --python /the/python/you/want/bin/python --markers --tags --indent 2
{
  "path": "/the/python/you/want/bin/python",
  "compatible_tags": [
    ...
    "python_full_version": "3.8.13",
    "python_version": "3.8",
    "sys_platform": "linux"
  }
}
Cut-paste that JSON into a file you check into your repo and add a BUILD next to it with a
file
target owning it. Finally, you're ready to point to that in your
python_awslambda
target with
complete_platforms=["address/of/the/complete_platform_json_file:target"]
.
You'll only need to go through this process of creating a complete platform JSON file once for each container image. You can then just re-use the JSON file target in all your
python_awslambda
s that will be deployed in that container image.
b
Thank you. I will give it a try.
I tried here, but it did not work. I will share the reproduced repo.