Hi there, I’m relatively new to pants ecosystem. H...
# general
f
Hi there, I’m relatively new to pants ecosystem. Has anyone faced the issue with pants failing to build wheels for grpcio in M1? If yes, how did you guys solve it?
👋 1
h
Hi, please give a lot more detail, including the command you ran, the relevant parts of relevant BUILD files and requirements files (e.g., requirements.txt/pyproject.toml) and the error message you got (running with
--print-stacktrace
)
s
Hi Sathvik. This is a shot in the dark, but I've had* issues building
grpcio
on M1 with pants. I had to add
Copy code
[subprocess-environment]
env_vars = [
  'GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=TRUE',
  'GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1',
  'GRPC_BUILD_WITH_BORING_SSL_ASM=',
]
to my
pants.toml
h
Aha, thanks @silly-queen-7197, that is likely the issue. Based on the stack trace @future-crowd-69462 DMd me, the error is a compilation error due to attempting to building the sdist, which requires various env vars to be plumbed through to the sandbox.
f
Thanks @silly-queen-7197 @happy-kitchen-89482. I have added the env variables but still this error keeps recurring. Not really sure what’s been happening though. These are my env variables if that could help
Copy code
env_vars = [
    "SSH_AUTH_SOCK",
    "GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1",
    "GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1",
    "GRPC_BUILD_WITH_BORING_SSL_ASM=1",
]
h
Are you able to install that package on your M1 using
pip
?
Basically without access to your system, or at least a LOT more information than you've provided, it'll be hard to figure out. So you'll have to do some more digging here. The basic framework of the problem is this: There is no published wheel for grpcio on M1. So Pants has to build the wheel from the sdist (which it does by delegating to Pip).
And that build is failing. So one of two things may be happening: 1) If this does build when you install it via Pip directly, then the difference is that Pants runs Pip in an isolated sandbox, so not all env vars are available, and you have to punch them through as @silly-queen-7197 explained. 2) If this doesn't build even directly under Pip, then you have to debug that first, and then revert to 1).
f
Have tested building my pants package by adding the env variables as suggested by @silly-queen-7197. No luck with that either.
h
So this is where you start digging into what is different between the sandboxed pip run that Pants does (via Pex) and the unsandboxed standalone pip run. It's very likely to be one or more missing env vars
for example, try adding PATH to that list
👍 1
If you run with
--keep-sandboxes=on_failure
then Pants will log the location of the sandbox that failed, and you can cd into it and play around
there is a
__run.sh
in the sandbox that will rerun the process
So you can tweak env vars, then
./__run.sh
until things work
Actually, I think running
./__run.sh
manually will have access to your entire environment
so things might work
and then you have to figure out which env vars are missing when Pants runs in the sandbox