gifted-afternoon-62260
08/05/2020, 10:07 AMhundreds-father-404
08/06/2020, 4:29 PMhundreds-father-404
08/06/2020, 4:29 PMgifted-afternoon-62260
08/07/2020, 9:30 AMgifted-afternoon-62260
08/07/2020, 9:32 AM.pex
built with Pants on our x86 desktop/laptop doesn't run on those devices (because of their ARM64 architecture). In an ideal world we could build ARM-compatible binaries on our workstation/CI, but an intermediate solution could be to run Pants directly on an ARM device.gifted-afternoon-62260
08/07/2020, 9:37 AM~
, a subtle WSL gotcha).hundreds-father-404
08/07/2020, 1:49 PMgifted-afternoon-62260
08/07/2020, 3:25 PMhundreds-father-404
08/07/2020, 3:28 PMpython_binary
I use pipx
to install Pex, personally. Then you can run something like pex --platform=manylinux2014_x86_64-cp-38-cp38 cryptography -o foo.pex
Once you find a platform string that works, add platforms=["$platform"]
to your python_binary
hundreds-father-404
08/07/2020, 3:28 PMpex --help
has some good info toogifted-afternoon-62260
08/07/2020, 3:37 PMhundreds-father-404
08/07/2020, 3:39 PMhundreds-father-404
08/07/2020, 3:40 PMgifted-afternoon-62260
08/07/2020, 3:51 PMlinux-aarch64
/ linux-armv7l
that I'm after)gifted-afternoon-62260
08/07/2020, 4:08 PM"linux-x86_64-cp-37-cp37"
hundreds-father-404
08/07/2020, 4:08 PMcp37m
at the endhundreds-father-404
08/07/2020, 4:09 PMcp38
, but every earlier Python version ends in m
for the abi taghundreds-father-404
08/07/2020, 4:09 PMlinux-x86_64-cp-37-cp37m
gifted-afternoon-62260
08/07/2020, 4:10 PMFailed to execute PEX file. Needed manylinux2014_x86_64-cp-27-cp27mu compatible dependencies for:
1: protobuf
But this pex only contains:
protobuf-3.12.2-cp37-cp37m-manylinux1_x86_64.whl
hundreds-father-404
08/07/2020, 4:10 PMgifted-afternoon-62260
08/07/2020, 4:11 PMpants.toml
is "==3.7.8"gifted-afternoon-62260
08/07/2020, 4:11 PMgifted-afternoon-62260
08/07/2020, 4:11 PM./pants binary src/py/<org>/<pkg>:<pkg>-bin
18:09:04 [WARN] <string>:1: DeprecationWarning: invalid escape sequence \/
18:09:04.16 [INFO] Wrote <pkg>-bin.pex
hundreds-father-404
08/07/2020, 4:12 PM--platform
twice. With Pants, you put multiple values in the list.
even though the interpreter constraint in pants.toml is “==3.7.8”Yeah, this is the incomplete warning on those Pants docs.
platform
overrides Python interpreter constraints because the platform already specified a more fine grained interpreter versionhundreds-father-404
08/07/2020, 4:12 PMpython_binary
target definition?gifted-afternoon-62260
08/07/2020, 4:13 PMpython_binary(
name = "<pkg>-service",
dependencies = [
":<pkg>",
],
platforms = [
"linux-x86_64-cp-37-cp37m",
],
entry_point = "org.pkg.main:main",
)
hundreds-father-404
08/07/2020, 4:15 PMdist/<pkg>-bin.pex
?
./pants dependencies --type=3rdparty --transitive src/py/<org>/<pkg>:<pkg>-bin
will also give you the list of every 3rd party req that is being installedgifted-afternoon-62260
08/07/2020, 4:18 PMgifted-afternoon-62260
08/07/2020, 4:19 PM./pants dependencies --type=3rdparty --transitive src/py/...
18:18:52 [INFO] initializing pantsd...
18:18:52 [WARN] File handle limit is capped to: 4096. To avoid 'too many open file handle' errors, we recommend a limit of at least 10000: please see <https://pants.readme.io/docs/troubleshooting#too-many-open-files-error> for more information.
18:18:55 [INFO] pantsd initialized.
18:18:55 [WARN] <string>:1: DeprecationWarning: invalid escape sequence \/
protobuf==3.12.2
hundreds-father-404
08/07/2020, 4:20 PMunzip -p dist/<pkg>-bin PEX-INFO
?
That file is what stores all the metadata about your built Pex. It’s used to determine how to run your built Pexgifted-afternoon-62260
08/07/2020, 4:22 PMgifted-afternoon-62260
08/07/2020, 4:22 PM{
"always_write_cache": false,
"build_properties": {
"class": "CPython",
"pex_version": "2.1.14",
"platform": "manylinux2014_x86_64",
"version": [
2,
7,
17
]
},
"code_hash": "8134d691270357b1cd3fae9f3c2e629fdc8c161a",
"distributions": {
"protobuf-3.12.2-cp37-cp37m-manylinux1_x86_64.whl": "adba80a20818548435da928289efd151b710e821",
"setuptools-49.2.1-py3-none-any.whl": "0eb682df0273c6573c4056eed158b3f9498fce4a",
"six-1.15.0-py2.py3-none-any.whl": "0cb007434fc9c1d2ee600dbd964088b69f5d670a"
},
"emit_warnings": false,
"entry_point": "<org>.<pkg>.main:main",
"ignore_errors": false,
"inherit_path": "false",
"interpreter_constraints": [],
"pex_path": null,
"requirements": [
"protobuf==3.12.2",
"setuptools==49.2.1; python_version >= \"3.5\"",
"six==1.15.0; python_version != \"3.0.*\" and python_version != \"3.1.*\" and python_version != \"3.2.*\" and python_version >= \"2.7\""
],
"strip_pex_env": true,
"unzip": false,
"zip_safe": true
}
hundreds-father-404
08/07/2020, 4:24 PMpipx install pex
, or pip install pex
, or downloading the binary from https://github.com/pantsbuild/pex/releases
Once you get things working how you’d like with Pex, it’s easier to figure out how to translate to Pants. It’s possible that this is a bug in how Pants calls Pex.gifted-afternoon-62260
08/07/2020, 4:25 PMhundreds-father-404
08/07/2020, 4:42 PMshebang='#!/usr/bin/env python3.7
on the python_binary
. That will force the runtime to use that shebang, rather than the normal mechanismenough-analyst-54434
08/07/2020, 5:00 PMpython3.7 dist/<pkg>-bin
? IE run the PEX file using python3.7 instead of running the PEX file directly.enough-analyst-54434
08/07/2020, 5:00 PMgifted-afternoon-62260
08/07/2020, 5:10 PMgifted-afternoon-62260
08/08/2020, 10:55 AMgifted-afternoon-62260
08/08/2020, 11:00 AMplatforms = ["linux-aarch64-cp-37-cp37m"],
it still says "platform": "manylinux2014_x86_64",
in the resulting PEX-INFOhundreds-father-404
08/08/2020, 4:02 PMgifted-afternoon-62260
08/11/2020, 8:37 AMpex ... --platform=manylinux2014_aarch64-cp-37-cp37m
the resulting PEX_INFO says "platform": "manylinux2014_x86_64"
, shouldn't it be "platform": "manylinux2014_aarch64"
(same when I run it through Pants with either manylinux2014_aarch64-cp-37-cp37m
or linux-aarch64-cp-37-cp37m
)? I'm sorry but I didn't find anything related to that in the python-setup
reference, which bit were you referring to?enough-analyst-54434
08/11/2020, 3:10 PM--platform=...
argument(s) indicate the platform of the wheels to resolve and install in the PEX file.
For example, on my linux machine:
$ pex --platform=manylinux2014_aarch64-cp-37-cp37m pex -o example.pex
$ unzip -qc example.pex PEX-INFO | jq .
{
"always_write_cache": false,
"build_properties": {
"class": "CPython",
"pex_version": "2.1.13",
"platform": "manylinux2014_x86_64",
"version": [
3,
8,
5
]
},
"code_hash": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"distributions": {
"pex-2.1.15-py2.py3-none-any.whl": "bc4c28769a8f357bba9579aa5e24534b622d4ada"
},
"emit_warnings": true,
"ignore_errors": false,
"inherit_path": "false",
"interpreter_constraints": [],
"pex_path": null,
"requirements": [
"pex==2.1.15; python_version != \"3.0.*\" and python_version != \"3.1.*\" and python_version != \"3.2.*\" and python_version != \"3.3.*\" and python_version != \"3.4.*\" and python_version < \"3.9\" and python_version >= \"2.7\""
],
"strip_pex_env": true,
"unzip": false,
"zip_safe": true
}
gifted-afternoon-62260
08/11/2020, 3:48 PM