best-florist-45041
12/16/2021, 6:25 PMpants tailor
will create both python_sources()
and docker_image()
thus creating a name conflict if it sees a Dockerfile and python code in the same location.
1) Have [python] interpreter_constraints = [">=3.9"]
, but somehow the pex_binary target, when placed inside the docker image, calls python3.8
(and fails, because I'm using a 3.9 image).
2) In my situation the entrypoint is defined through a third-party helm chart which needs to know about the target python package to import. Hence I only need a python env with my code in the image. I found using PEX_TOOLS=1 ./archive.pex venv ...
works perfectly with the corresponding include_tools
option in pex_binary
. Except that https://pex.readthedocs.io/en/v2.1.57/recipes.html#pex-app-in-a-container refers to env vars like PEX_PYTHON=3.9
, which appear to not do anything (like patch the issue (1))hundreds-father-404
12/16/2021, 6:28 PMbest-florist-45041
12/16/2021, 6:30 PM./pants tailor
10:28:59.37 [INFO] Initializing scheduler...
10:28:59.44 [INFO] Scheduler initialized.
Created src/stuff/BUILD:
- Add docker_image target docker
- Add python_sources target stuff
⯠./pants package src/stuff::
10:29:28.59 [ERROR] 1 Exception encountered:
DuplicateNameError: A target already exists at 'src/stuff/BUILD' with name 'stuff' and target type 'docker_image'. The 'python_sources' target cannot use the same name.
this directory had two files: Dockerfile + single python filebest-florist-45041
12/16/2021, 6:30 PMbest-florist-45041
12/16/2021, 6:31 PMdocker_image()
python_sources()
hundreds-father-404
12/16/2021, 6:44 PMfew-arm-93065
12/16/2021, 7:35 PMhundreds-father-404
12/16/2021, 7:40 PMunzip
on it and look at the PEX-INFO
file? That has all the metadata for the PEXfew-arm-93065
12/16/2021, 7:51 PM{
"bootstrap_hash": "a123f8e91baf9753da4866822c19607577f7947d",
"build_properties": {
"pex_version": "2.1.54"
},
"code_hash": "8a06287e5519b727046aa317d69d062ebfc89950",
"distributions": {
"boto3-1.20.21-py3-none-any.whl": "39a44c866fad0505a4f36756ef8982f80b72eaf9",
etc...
},
"emit_warnings": false,
"entry_point": "...",
"ignore_errors": false,
"includes_tools": false,
"inherit_path": "false",
"interpreter_constraints": [],
"pex_hash": "b083681a3c1646ad87398dd31bf1ae755c85fd68",
"pex_path": null,
"requirements": [
"boto3==1.20.21",
etc...
],
"strip_pex_env": true,
"venv": false,
"venv_bin_path": "false",
"venv_copies": false
}
hundreds-father-404
12/16/2021, 7:52 PMinterpreter_constraints
is set to []
...What Pants version is this?
What happens if you set interpreter_constraints=["==3.9.*"]
on the pex_binary
?best-florist-45041
12/16/2021, 7:57 PM"interpreter_constraints": []
in PEX-INFO. This is pants==2.9.0.dev3
and thus pex==2.1.56
few-arm-93065
12/16/2021, 7:57 PMfew-arm-93065
12/16/2021, 8:00 PMENV PEX_VERBOSE=2
to my dockerfile isn't producing any additional output, which is odd. the only error I get is
11:58:13.62 [INFO] Completed: Building docker image [redacted]
/usr/bin/env: 'python3.8': No such file or directory
hundreds-father-404
12/16/2021, 8:02 PMplatform
on the pex_binary
perhaps?best-florist-45041
12/16/2021, 8:02 PMplatforms=["linux_x86_64-cp-39-cp39"]
few-arm-93065
12/16/2021, 8:03 PMplatforms=[
"current",
"manylinux2014_aarch64-cp-310-cp310"
]
hundreds-father-404
12/16/2021, 8:04 PMplatforms
is set, we don't set interpreter_constraints
. John has pointed out in the past that is probably incorrect behavior, which we should change
In the meantime, the workaround is to set shebang="python3.9"
on the pex_binary
best-florist-45041
12/16/2021, 8:15 PMshebang="/usr/local/bin/python3.9"
best-florist-45041
12/16/2021, 8:17 PM/usr/bin/env python3.9
is what you meant?hundreds-father-404
12/16/2021, 8:19 PMfew-arm-93065
12/16/2021, 8:21 PMhundreds-father-404
12/17/2021, 6:31 PM