clever-table-90691
07/14/2020, 4:43 PM./pant awslambda
, we are currently on PANTS v1.28.0
When pants is building an awlambda target, it seems to be always using python 2.7 even there is python 3.8 installed on our CI/CD environment,
we’ve also specified the interpreter_constraints = ["CPython>=3.7"]
in the pants.ci.toml file
Is there a way to enforce it to use python 3.8?
Here is part of the trace stack:
pid: 14794 -> /usr/bin/python2.7 /tmp/process-executionAmQ08c/pex_root/pip.pex/d3323a933395f1fea4b421b92e99bd2c3d524e6c --disable-pip-version-check --isolated --no-python-version-warning -q --cache-dir /tmp/process-executionAmQ08c/pex_root download --dest /tmp/tmpsuxiy3/manylinux2014_x86_64-cp-38-cp38 --index-url <https://pypi.org/simple/> --header Cache-Control:max-age=3600 --retries 5 --timeout 15 --platform manylinux2014_x86_64 --implementation cp --python-version 38 --abi cp38 --only-binary :all: --constraint constraints.txt boto3==1.12.20 idna<2.10 requests==2.23.0 ruamel.yaml==0.16.10 snowflake-sqlalchemy==1.2.3 raised Executing /usr/bin/python2.7 /tmp/process-executionAmQ08c/pex_root/pip.pex/d3323a933395f1fea4b421b92e99bd2c3d524e6c --disable-pip-version-check --isolated --no-python-version-warning -q --cache-dir /tmp/process-executionAmQ08c/pex_root download --dest /tmp/tmpsuxiy3/manylinux2014_x86_64-cp-38-cp38 --index-url <https://pypi.org/simple/> --header Cache-Control:max-age=3600 --retries 5 --timeout 15 --platform manylinux2014_x86_64 --implementation cp --python-version 38 --abi cp38 --only-binary :all: --constraint constraints.txt boto3==1.12.20 idna<2.10 requests==2.23.0 ruamel.yaml==0.16.10 snowflake-sqlalchemy==1.2.3 failed with 1
clever-table-90691
07/14/2020, 4:44 PM--python-setup-interpreter-constraints="['CPython>=3.8']"
but it’s still using python 2.7hundreds-father-404
07/14/2020, 4:49 PMpython_awslambda
target definition in your BUILD file?clever-table-90691
07/14/2020, 4:57 PMruntime="python3.8"
hundreds-father-404
07/14/2020, 5:07 PMclever-table-90691
07/14/2020, 5:59 PMclever-table-90691
07/14/2020, 6:00 PMclever-table-90691
07/14/2020, 6:00 PMERROR: No matching distribution found for ruamel.ordereddict; platform_python_implementation == "CPython" and python_version <= "2.7" (from ruamel.yaml==0.16.10->-c constraints.txt (line 53))
clever-table-90691
07/14/2020, 6:02 PM./pants awslambda
command completes without error when we ran it in a venv with python 3.8witty-crayon-22786
07/14/2020, 6:45 PMpid: 14794 -> /usr/bin/python2.7 /tmp/process-executionAmQ08c/pex_root/pip.pex/d3323a933395f1fea4b421b92e99bd2c3d524e6c
bit does indicate that pex is using pip under python 2.7 to build this targetwitty-crayon-22786
07/14/2020, 6:45 PMBUILD
file? do you override the constraints on the target?witty-crayon-22786
07/14/2020, 6:46 PMhundreds-father-404
07/14/2020, 6:49 PMdoes the AWS plugin do thatIt does not. We determine interpreter constraints based on the transitive closure of targets. We merge them into a single set of constraints But because we set
--platform
, that doesn’t even matter. --platform
overrides interpreter constraints with Pex. You can’t specify both at the same time.
And in the original Pex command, it looks like we indeed are setting --platform
correctly.
the ./pants awslambda command completes without error when we ran it in a venv with python 3.8I think this is likely more relevant than the
compatibility
field or the interpreter_constraints
option. I suspect there’s a bug with the venv somehow leaking.witty-crayon-22786
07/14/2020, 6:53 PM./pants -ldebug ...
it should render a lot more information about how pex is being invoked.witty-crayon-22786
07/14/2020, 6:54 PMwitty-crayon-22786
07/14/2020, 6:54 PMclever-table-90691
07/15/2020, 11:48 AMwitty-crayon-22786
07/15/2020, 4:41 PM[2020-07-15T11:40:40.222Z] pex: Selecting runtime interpreter
[2020-07-15T11:40:40.222Z] pex: Using the current interpreter /usr/bin/python2.7 since no constraints have been specified and PYTHONPATH is not set.
[2020-07-15T11:40:40.222Z] pex: Selecting runtime interpreter: 0.1ms
… so it looks like however you are setting the interpreter_constraints is not stickingwitty-crayon-22786
07/15/2020, 4:42 PM<http://pants.ci|pants.ci>.toml
in use in your output though… should it be?clever-table-90691
07/15/2020, 5:46 PMexport PANTS_CONFIG_FILES=<http://pants.ci|pants.ci>.toml
witty-crayon-22786
07/15/2020, 5:48 PMPANTS_CONFIG_FILES=<http://pants.ci|pants.ci>.toml ./pants help-advanced python-setup
should show you the option appliedwitty-crayon-22786
07/15/2020, 5:49 PMclever-table-90691
07/15/2020, 6:21 PMclever-table-90691
07/15/2020, 6:21 PMhundreds-father-404
07/15/2020, 6:24 PMlambdex.pex
, i.e. the pex that runs the Lambdex tool, does not actually have constraints applied. We set it to lambdex.get_requirement_specs()
, but that results in None, meaning we have no constriants.
However, that is different than when we resolve requirements, and it looks like the issue is that resolving requirements is not doing the right thing.witty-crayon-22786
07/15/2020, 6:28 PMhundreds-father-404
07/15/2020, 6:29 PM--platform
, --interpreter-constraints
no longer apply. We had that wrong originally, and it took John walking me through it to fix that in Pants.witty-crayon-22786
07/15/2020, 6:37 PMhundreds-father-404
07/17/2020, 7:42 AMwhich -a python
? This is Pants 1.28, right? It’d also help if you can share the constraints file if y’all are able to, even if some of it is stripped.hundreds-father-404
07/17/2020, 7:44 AM