Is it at all possible to have pants build for linu...
# general
h
Is it at all possible to have pants build for linux_armv7l? I get the following error:
Copy code
InvalidTargetException: BUILD:7: Values for the 'platform' field in target //:linux_arm64 must be one of ['linux_arm64', 'linux_x86_64', 'macos_arm64', 'macos_x86_64'], but 'linux_armv7l' was provided.
b
What target is erroring there? Can you share a bit more context. Pants can definitely cross-build, say, a
pex_binary
target for armv7l, if one has an appropriate complete_platforms JSON file and all dependencies have pre-built wheels
h
Those platforms are the ones Pants itself expects to run on
So I assume you’re running Pants on a … I don’t actually know what armv7s are out there? Raspberry Pi?
h
Hi sorry - wasn't sure how much context to include. I'm trying to build on my intel mac 2019 for an old pi (maybe 2015). I have something like so in my root build:
Copy code
docker_environment(
    name="linux",
    image="pychris/python:3.11",
    fallback_environment="local"
)

docker_environment(
    name="linux_arm64",
    image="pychris/python:3.11",
    platform="linux_armv7l",
    fallback_environment="local"
)

local_environment(name="local")

__defaults__(all=dict(environment="default"))
And something like so for my pi
Copy code
pex_binary(
    name="api",
    entry_point="gunicorn",
    dependencies=[":src"],
    args=[
        "dh.cannery.proxy.api:create_app",
        "--access-logfile=-",
        "--bind",
        "0.0.0.0:8094",
        "--worker-class",
        "aiohttp.GunicornWebWorker",
    ],
    restartable=True,
    environment="linux_arm64",
)
Then I'll run a pants package to build my PEX on my laptop (mac) and then "deploy" that pex to the Pi
Maybe this is what I'm misunderstanding:
Pants can definitely cross-build, say, a pex_binary target for armv7l, if one has an appropriate complete_platforms JSON file and all dependencies have pre-built wheels
I saw that mentioned when searching around but I can't make sense of the documentation nor how to implement it at all. is there a guide somewhere which explains what's needed? this sort of functionality will be hugely helpful for our team and is sort of why (along with mono repo stuff) i chose pants for our projects
b
h
This isn't something I can use just yet?
b
ah sorry, I'm being ambiguous: no, all the features are already usable, just the docs for that existing feature are better in the next release
🙌 1
h
thank you! i'll have a go with this and report back how I go. appreciate you taking the time to help me on this query
Something I"m not understanding is that if i pip install aiohttp on the machine i'm trying to deploy to, it'll find the right wheel and install it. but when i'm doing it locally I get the following issue:
Copy code
stderr:
No pre-built wheel was available for aiohttp 3.10.8.
Successfully built the wheel aiohttp-3.10.8-cp39-cp39-macosx_10_9_x86_64.whl from the sdist aiohttp-3.10.8.tar.gz but it is not compatible wi
th the requested foreign target complete platform cp311-cp311-manylinux_2_36_armv7l.
You'll need to build a wheel from aiohttp-3.10.8.tar.gz on the foreign target platform and make it available to Pex via a `--find-links` repo
 or a custom `--index`.
oh its installing from piwheels
So this is all working now (i think) but I can't help but notice when I build a pex the hashbang at the top is python3.9 despite me specifying in my pants.toml it is to use python 3.11 can you please elaborate on what this mean or point me to some docs? is this a pex specific thing?
/bin/python is the only place i have 3.9. this means that the system i'm deploying the pex to will also need 3.9. Is this just needed to run pex? and then the application will run with 3.11?
Aight sorry all sorted - i didn't know i can specify the shebang in the pex_binary which is mean now. thanks for everything guys
👍 1
b