adorable-thailand-45835
04/22/2022, 7:24 PMpython_awslambda
in my Mac but I'm getting this error when I run ./pants package appcode/api/transaction_details/src/main.py
:
pip._vendor.packaging.markers.UndefinedEnvironmentName: '*python_full_version' does not exist in evaluation environment.*
pid 81510 -> /Users/rifonseca/.cache/pants/named_caches/pex_root/venvs/44f0d229c64d262df3c9196eaa181a922a2a17cd/81d027995b16273d21e19dc7b1441abee1a3e3d1/pex --disable-pip-version-check --no-python-version-warning --exists-action a --isolated -q --cache-dir /Users/rifonseca/.cache/pants/named_caches/pex_root --log /private/var/folders/63/28d_yhnj2tn6f3xg1g_mp0lr0000gq/T/process-executionnyaMyQ/.tmp/tmp47qnomzj/pip.log download --dest /private/var/folders/63/28d_yhnj2tn6f3xg1g_mp0lr0000gq/T/process-executionnyaMyQ/.tmp/tmphaqx3pp0/cp39-cp39-linux_x86_64 --only-binary all --no-deps --requirement 3rdparty/python/default.lock --platform manylinux2014_x86_64 --platform linux_x86_64 --implementation cp --python-version 39 --abi cp39 --index-url https://pypi.org/simple/ --retries 5 --timeout 15 exited with 2 and STDERR:
Failed to resolve for platform linux_x86_64-cp-39-cp39. Resolve requires evaluation of unknown environment marker: 'python_full_version' does not exist in evaluation environment.Reading through the docs, I found this:
Running from macOS and failing to build?
AWS Lambdas must run on Linux, so Pants tells PEX and Pip to build for Linux when resolving your third party dependencies. This means that you can only use pre-built wheels (bdists). If your project requires any source distributions (sdists) that must be built locally, PEX and pip will fail to run.
If this happens, you must either change your dependencies to only use dependencies with pre-built wheels or find a Linux environment to runWondering how to do I tell../pants package
./pant package....
to only use pre-built wheels? I know if I was using pip
directly, I could pass the --only-binary=:all
flag.hundreds-father-404
04/22/2022, 7:34 PMhundreds-father-404
04/22/2022, 7:34 PMadorable-thailand-45835
04/22/2022, 8:33 PMpex3 interpreter inspect --markers --tags
to generate a complete platform json and then used it to create a complete_platform.json
in the local directory containing the generated marker_environment
and compatible_tags
. I then updated my python_awslambda
with complete_platforms=["./complete_platforms.json"]
. I'm now getting this error:
ValueError: The addressis not generated by theappcode/api/transaction_details/src/complete_platforms.json
targetpython_sources
, which only generates these addresses:appcode/api/transaction_details/src:src
*appcode/api/transaction_details/src/__init__.py
*appcode/api/transaction_details/src/main.py
Did you mean to use one of those addresses?Thoughts?
adorable-thailand-45835
04/22/2022, 8:37 PMpex_binary(
name="main",
entry_point="main.py",
)
python_sources()
python_awslambda(
name="lambda",
runtime="python3.9",
handler="main.py:handler",
complete_platforms=["./complete_platforms.json"]
)
hundreds-father-404
04/22/2022, 9:19 PMComplete platforms should be addresses of file targets that point to files that contain complete platform JSON as described by PexMeaning, add this:
file(name="platforms", source="./complete_platforms.json")
Then, set complete_platforms=[":platforms"])
adorable-thailand-45835
04/22/2022, 9:28 PMpip._vendor.packaging.markers.UndefinedEnvironmentName: 'python_full_version' does not exist in evaluation environment.
pid 32167 -> /Users/rifonseca/.cache/pants/named_caches/pex_root/venvs/44f0d229c64d262df3c9196eaa181a922a2a17cd/81d027995b16273d21e19dc7b1441abee1a3e3d1/pex --disable-pip-version-check --no-python-version-warning --exists-action a --isolated -q --cache-dir /Users/rifonseca/.cache/pants/named_caches/pex_root --log /private/var/folders/63/28d_yhnj2tn6f3xg1g_mp0lr0000gq/T/process-execution44HIOZ/.tmp/tmpse5ogntr/pip.log download --dest /private/var/folders/63/28d_yhnj2tn6f3xg1g_mp0lr0000gq/T/process-execution44HIOZ/.tmp/tmp0ffclkld/cp39-cp39-linux_x86_64 --only-binary :all: --no-deps --requirement 3rdparty/python/default.lock --platform manylinux2014_x86_64 --platform linux_x86_64 --implementation cp --python-version 39 --abi cp39 --index-url <https://pypi.org/simple/> --retries 5 --timeout 15 exited with 2 and STDERR:
Failed to resolve for platform linux_x86_64-cp-39-cp39. Resolve requires evaluation of unknown environment marker: 'python_full_version' does not exist in evaluation environment.
Here is what the updated BUILD file looks like:
pex_binary(
name="main",
entry_point="main.py",
)
python_sources()
file(name="platforms", source="./complete_platforms.json")
python_awslambda(
name="lambda",
runtime="python3.9",
# Pants will convert this to `project.lambda_example:example_handler`.
handler="main.py:handler",
complete_platforms=[":platforms"]
)
hundreds-father-404
04/22/2022, 9:35 PMhundreds-father-404
04/22/2022, 9:35 PMadorable-thailand-45835
04/22/2022, 9:43 PMrequirements.txt
looks like:
Faker==13.4.0
pytest~=7.
enough-analyst-54434
04/22/2022, 9:59 PMadorable-thailand-45835
04/22/2022, 10:19 PMUnable to expand "lambda.zip". It is in an unsupported format
error. When I upload the generated zip to lambda, I notice that Faker is missing from the list of dependencies which is confirm by the error I get when I run the lambda: "errorMessage": "Unable to import module 'main': No module named 'faker'"
hundreds-father-404
04/22/2022, 10:31 PMYou need to delete your runtime setting. It's either runtime or complete_pmatform.@enough-analyst-54434 our error message is:
The `{self.alias}` target {self.address} must specify either a
`{self[PythonAwsLambdaRuntime].alias}` or
`{self[PexCompletePlatformsField].alias}` or both.
So, it was intentional, but a mistake it sounds like?enough-analyst-54434
04/22/2022, 10:54 PMenough-analyst-54434
04/22/2022, 11:04 PMadorable-thailand-45835
04/22/2022, 11:11 PMlambda.zip
and it doesn't seem to have the third-party dependencies (e.g. Faker)?enough-analyst-54434
04/22/2022, 11:15 PMadorable-thailand-45835
04/22/2022, 11:50 PMhundreds-father-404
04/22/2022, 11:51 PM...
adorable-thailand-45835
04/22/2022, 11:54 PMenough-analyst-54434
04/22/2022, 11:57 PMadorable-thailand-45835
04/23/2022, 12:01 AMadorable-thailand-45835
04/23/2022, 12:12 PMpex3 interpreter inspect --markers --tags
command on a host/image equivalent to the x86 with Python 3.9 used by Lambda? Also wondering if pants should include platform files for host/images used by lambda out of the box?happy-kitchen-89482
04/26/2022, 4:40 PMhappy-kitchen-89482
04/26/2022, 4:40 PMhappy-kitchen-89482
04/26/2022, 4:40 PMhappy-kitchen-89482
04/26/2022, 4:42 PMadorable-thailand-45835
04/26/2022, 4:43 PMhappy-kitchen-89482
04/26/2022, 4:48 PMhappy-kitchen-89482
04/26/2022, 4:51 PMadorable-thailand-45835
04/26/2022, 4:53 PMhappy-kitchen-89482
04/26/2022, 4:59 PMpex==2.1.82
(say) as a requirement, and then do something like this in the function:happy-kitchen-89482
04/26/2022, 5:00 PMimport sys
from pex.cli import pex
sys.argv = ["pex", "interpreter", "inspect", "--markers", "--tags"]
pex.main()
happy-kitchen-89482
04/26/2022, 5:00 PMhappy-kitchen-89482
04/26/2022, 5:02 PM"--output", "path/to/tmpfile"
to the sys.argv and then read from that fileadorable-thailand-45835
04/28/2022, 9:50 PMrgparse.ArgumentTypeError: Failed to load complete platform data from appcode/api/transaction_details/src/lambda_complete_platform.json: Expecting property name enclosed in double quotes: line 574 column 1 (char 21573)
BUILD.bazel:
pex_binary(
name="main",
entry_point="main.py",
)
python_sources()
file(name="mac_complete_platform", source="./mac_complete_platform.json")
file(name="lambda_complete_platform", source="./lambda_complete_platform.json")
python_awslambda(
name="lambda",
handler="main.py:handler",
runtime="python3.9",
complete_platforms=[
":lambda_complete_platform",
":mac_complete_platform"
]
)
adorable-thailand-45835
04/28/2022, 9:53 PMenough-analyst-54434
04/28/2022, 10:14 PMjson.load
and failing:
https://github.com/pantsbuild/pex/blob/9b889ff72f8dd90828dfc6ef0006e1a8388b885b/pex/resolve/target_options.py#L208-L217adorable-thailand-45835
04/28/2022, 10:56 PMenough-analyst-54434
04/28/2022, 11:53 PM}
at the end. I'll see if I can come up with a basic repro.adorable-thailand-45835
04/29/2022, 2:32 PM#BAZEL.bazel
python_awslambda(
name="lambda",
handler="main.py:handler",
runtime="python3.9",
complete_platforms=[
":lambda_complete_platform",
]
)
This results in the following error:
pip._vendor.packaging.markers.UndefinedEnvironmentName: 'python_full_version' does not exist in evaluation environment.
pid 8102 -> /Users/rifonseca/.cache/pants/named_caches/pex_root/venvs/44f0d229c64d262df3c9196eaa181a922a2a17cd/81d027995b16273d21e19dc7b1441abee1a3e3d1/pex --disable-pip-version-check --no-python-version-warning --exists-action a --isolated -q --cache-dir /Users/rifonseca/.cache/pants/named_caches/pex_root --log /private/var/folders/63/28d_yhnj2tn6f3xg1g_mp0lr0000gq/T/process-executionF1LKUc/.tmp/tmp57oxch7i/pip.log download --dest /private/var/folders/63/28d_yhnj2tn6f3xg1g_mp0lr0000gq/T/process-executionF1LKUc/.tmp/tmpzpshq15r/cp39-cp39-linux_x86_64 --only-binary :all: --no-deps --requirement 3rdparty/python/default.lock --platform manylinux2014_x86_64 --platform linux_x86_64 --implementation cp --python-version 39 --abi cp39 --index-url <https://pypi.org/simple/> --retries 5 --timeout 15 exited with 2 and STDERR:
Failed to resolve for platform linux_x86_64-cp-39-cp39. Resolve requires evaluation of unknown environment marker: 'python_full_version' does not exist in evaluation environment.
I get the same error if I list the mac_complete_platform
file by itself. Attache is the mac file.enough-analyst-54434
04/29/2022, 2:34 PMruntime="python3.9"
target attribute.adorable-thailand-45835
04/29/2022, 3:04 PMenough-analyst-54434
04/29/2022, 3:10 PMadorable-thailand-45835
04/29/2022, 3:19 PMcomplete_platform
files for the different AWS Lambda hosts as part of the python_awslambda
integration. It may also not hurt to update the docs with the exact commands on how to generate the platform files on dev machines (e.g. macs).happy-kitchen-89482
04/29/2022, 9:40 PMenough-analyst-54434
04/29/2022, 10:58 PM