hi - I'm having issues building a pex binary for d...
# general
q
hi - I'm having issues building a pex binary for different platforms. As a sanity check I'm trying to build a pex binary with
platforms
set to my current platform, which I'm looking up by running
pex --help
on my local system. Building the pex with
platforms
unset succeeds, but building the pex with the platform set to my system's string fails with a missing package error (pasted below). What would be the difference between running
pants package
in these two ways?
Copy code
ERROR: Could not find a version that satisfies the requirement grpc-google-iam-v1
ERROR: No matching distribution found for grpc-google-iam-v1
h
I would think this means nothing is distributed for the platform you have selected and is an issue with what is hosted on the registry this is expected to be pulled from and not specifically Pants.
e
A platform build assumes the platform is foreign and requires wheels: https://pypi.org/project/grpc-google-iam-v1/#files
This is because Pants (Pex (Pip)) can't cross-build from sources.
There is a solution though - just searching code / docs so I don't lie....
h
Hello!
A platform build assumes the platform is foreign and requires wheels:
See the warning at https://www.pantsbuild.org/docs/awslambda-python#step-3-run-package for more about this
e
Ok, the solution is the Pex
--resolve-local-platforms
flag which you can set up either in the
pex_binary.resolve_local_platforms=True
bool field or else globally via
[pex-binary-defaults] resolve_local_platforms = True
👍 1
As Eric points out though, this will only work for your current experiment on your machine.
Switch to another machine where the platform cannot be resolved to a local interpreter (Linux from Mac or vice-versa), and boom.
To support that case you must pre-build wheels for all targeted platforms and make them available on a custom server you configure pants to look at via
[python-repos]
.
q
ah ok that makes sense that it would be looking for a built version for the platform. Running with --resolve-local-platforms seems not to be working though likely something I'm doing, but yea makes sense that it wouldn't work as a solution in the long run. and ok, I believe I saw another thread on here about setting that up, or setting up a way to build the package from within Docker for the target system. I'll take a closer look, thank you!
❤️ 1