cold-vr-15232
03/03/2023, 7:47 PMenough-analyst-54434
03/03/2023, 7:51 PMpex_binary
target depend on the python_distribution
that uses env(...)
or does it depend on python_sources
? It needs to depend on the python_distribution
and only that - not the sources. You can zipinfo -1 my.pex
to find out. You should see .deps/*
entries for the python_distribution
wheel and no top-level source entries for things the wheel owns.enough-analyst-54434
03/03/2023, 7:55 PMsys.path
and win. It won't see the version. Only the .deps/
wheel will see that, but it will never get imported.enough-analyst-54434
03/03/2023, 7:56 PMPEX_VERBOSE=1 PEX_INTERPRETER=1 ./my.pex -c 'import thing.that.lives.next.to.version as thing; print(thing.__file__)'
enough-analyst-54434
03/03/2023, 7:57 PMenough-analyst-54434
03/03/2023, 7:59 PMpex_binary(.., execution_mode="venv")
since, in a venv, all the code, 1st party and 3rd, gets installed in site-packages of the venv.cold-vr-15232
03/03/2023, 8:05 PMcold-vr-15232
03/03/2023, 8:05 PMcold-vr-15232
03/03/2023, 8:41 PMenough-analyst-54434
03/03/2023, 8:44 PMpython_distribution
began it's life as a hack to support cython / C-extensions by letting setup.py deal with that. And the hack has never been revisited comprehensively, only moles have been whacked.enough-analyst-54434
03/03/2023, 8:45 PMcold-vr-15232
03/03/2023, 8:47 PMenough-analyst-54434
03/03/2023, 8:48 PMcold-vr-15232
03/03/2023, 8:49 PMenough-analyst-54434
03/03/2023, 8:50 PMpython_distribution
- it does not make as much sense for a pex_binary
. The version a Pex uses in Pants is the sources as they are right now in the repo!enough-analyst-54434
03/03/2023, 8:50 PMcold-vr-15232
03/03/2023, 8:53 PMenough-analyst-54434
03/03/2023, 8:53 PMenough-analyst-54434
03/03/2023, 8:54 PMenough-analyst-54434
03/03/2023, 8:55 PMenv
parametrize any field in a build, save for name
for sanity sake, so best read up on the fields.cold-vr-15232
03/03/2023, 8:55 PMenough-analyst-54434
03/03/2023, 8:56 PMcold-vr-15232
03/03/2023, 8:57 PMcold-vr-15232
03/03/2023, 8:58 PMenough-analyst-54434
03/03/2023, 8:58 PMenv
in a PEX permanent env var your PEXed code could read - say VERSION
.cold-vr-15232
03/03/2023, 9:08 PMenough-analyst-54434
03/03/2023, 9:14 PM$ git diff
diff --git a/pants.toml b/pants.toml
index 0cecdef..7715879 100644
--- a/pants.toml
+++ b/pants.toml
@@ -1,5 +1,5 @@
[GLOBAL]
-pants_version = "2.15.0"
+pants_version = "2.16.0.dev7"
backend_packages = [
"pants.backend.python",
And then:
$ pants help pex_binary
`pex_binary` target
-------------------
A Python target that can be converted into an executable PEX file.
PEX files are self-contained executable files that contain a complete Python environment capable of running the target. For more information, see <https://www.pantsbuild.org/v2.16/docs/pex-files>.
Activated by pants.backend.python
Valid fields:
args
type: Iterable[str] | None
default: None
Freeze these command-line args into the PEX. Allows you to run generic entry points on specific arguments without creating a shim file.
...
env
type: Dict[str, str] | None
default: None
Freeze these environment variables into the PEX. Allows you to run generic entry points on a specific environment without creating a shim file.
...
cold-vr-15232
03/03/2023, 9:25 PMenough-analyst-54434
03/03/2023, 10:10 PM