One more hopefully simple question. I am trying to...
# general
a
One more hopefully simple question. I am trying to resolve constraints and build the
cryptography
library. This requires rust and openssl. It fails to compile because it cannot find headers for openssl.
Copy code
build/temp.macosx-12.1-arm64-3.9/_openssl.c:575:10: fatal error: 'openssl/opensslv.h' file not found
  #include <openssl/opensslv.h>
I am surprised by this, because I explicitly set some env variables to avoid this.
Copy code
$ echo $CPPFLAGS $LDFLAGS $PKG_CONFIG_PATH 
-I/opt/homebrew/opt/openssl@3/include -L/opt/homebrew/opt/openssl@3/lib /opt/homebrew/opt/openssl@3/lib/pkgconfig
Copy code
$ ls /opt/homebrew/opt/openssl@3/include/openssl/opensslv.h 
/opt/homebrew/opt/openssl@3/include/openssl/opensslv.h
What should I change to get cargo to look in the right spot for that file?
h
Check out https://www.pantsbuild.org/docs/reference-python-native-code#advanced-options. Looks like the docs are lying about the default, the default is actually
os.environ.get("CPPFLAGS", "")
Also we have a bug in that code that we are not invalidating Pantsd, OOF. This was code written a long time ago. Try using
--no-pantsd
or explicitly setting the options
--python-native-code-cpp-flags
and
--python-native-code-ld-flags
e
a
this is a dumb question but if I have
CPPFLAGS
set in my shell, shouldn't that get passed on to any child process spawned by me in that shell, i.e. pants -> cargo -> clang?
e
Nope
a
oh lol
that explains it
thanks
h
We still mix in
python-native-code
.
pex_cli.py
line 129. I've tried a few times to get rid of
python-native-code
in favor of something like
subprocess-environment
, but I couldn't figure out how to not break our deprecation policy. That subsystem is so random, it's a holdover from v1
e
Ah, yeah. Eric is right. The env var business is super confusing.
💯 1
h
h
I think I'd be fine with just breaking, so we can get rid of that complexity
h
If we do that, we should keep the options around but turn them off. That violates the policy:
Deprecated options must behave the same as before.
But at least better than Pants complaining the option does not exist, and the deprecation message will point you to how to fix things
As mentioned in the ticket, we really need more thinking about env vars now that we have multiple languages. Specifically whether to move
[subprocess-environment]
to
[python]
imo
a
wait but i'm not crazy though right, if i just call
fork()
in c, the child process and the parent have the same env, right? 🙂
this worked btw
explicitly setting the options 
--python-native-code-cpp-flags
 and 
--python-native-code-ld-flags
h
Yeah, that's correct! What I suspect is happening is that Pants needs to pass the correct env vars to the initial child process. Pants tries doing things hermetically and strips all env vars, except for a few blessed ones like the
[python-native-code]
options +
[subprocess-environment]
this worked btw
Excellent. What about if you go back to using the default and do
rm -rf .pids
first to force Pantsd to restart? Given that you have explicitly set your
$CPPFLAGS
and
$LDFLAGS
to the correct value, the default should work other than the Pantsd invalidation bug
a
trying...
can't tell for sure if it tried to rebuild
cryptography
but it didn't fail!
🙌 1
h
ah, yeah if it was already built, then you'll be hitting the cache on-disk. You could use
--no-local-cache --no-pantsd
to be extra extra confident, but I think you're in the clear. FYI the cache would not be used if
LDFLAGS
and
CPPFLAGS
was set to a different value because the input to building the PEX would have changed. You can convince yourself of this by trying another run with
--python-native-code-cpp-flags=nonsense
, and Pants should try rebuilding the PEX.
a
running with
--no-local-cache --no-pantsd
was also successful. I couldn't force it to fail with
--python-native-code-cpp-flags=nonsense
which is a little 👻 to me. But I am also still not sure why it even tried to build cryptography from source, given that my constraint was
cryptography==36.0.1
and a wheel for that exists
cryptography-36.0.1-cp36-abi3-macosx_10_10_universal2.whl
https://pypi.org/project/cryptography/#files so maybe it just used the wheel?
👀 1
either way, you once again solved my issue, taught me more stuff and were extremely patient and kind in the process. yall are the best
❤️ 2
b
That's lovely to hear. @acoustic-librarian-3937 would it be okay for us to quote you? (With or without attribution, whichever you prefer.)
a
Go for it! I think I prefer to be anonymous for now if that is cool with you
1
h
ah Ryan what Pants version is this?
a
2.9.0 still
haven't gotten around to trying 2.10 yet 🙂
but don't worry about digging into that Eric unless you want to. I think I have what I need for now
h
Hm, I thought that we had updated Pex to understand
universal2
and backported that to 2.9, but need to check the changelog if that got cherry-picked. (logging off for the night, will check tomorrow if someone doesn't beat me)
a
pretty sure you did, because it was using the wheel earlier today
I only know this because a coworker couldn't build it from source due to missing rust and I noticed I was using the wheel
Copy code
Collecting cryptography>=3.3.1
  Downloading cryptography-36.0.1-cp36-abi3-macosx_10_10_universal2.whl
have a good night!
b
Thanks Ryan, and good luck. Keep on asking questions! 🙂
l
I'll echo what @acoustic-librarian-3937 said about the very high level of support here; I come from Java-land and did a lot with Gradle, and I know that build tools are not simple and have to do a ton of little things well, and so the Pants folks are getting complex questions from all angles. I'm making steady progress with shifting our current setup (which has some warts that make the transition to Pants a bit more difficult) and have been thinking about whether a blog/article/etc about our transition would be helpful for other Pants users (don't hold me to that, I may not want to divulge the warts of our current setup 🙂 )
🙌 3
e
Re
universal2
I dropped the ball. The PR is here and still needs cherry-pick: https://github.com/pantsbuild/pants/pull/14256 It looks like that landed on the 26th and I had gone on OOO for a few weeks the 25th (technically). I'll get the cherry-pick up here presently.
🙌 1
Cherry-picked but not without problems: https://github.com/pantsbuild/pants/pull/14617
b
@lively-exabyte-12840 that absolutely would be valuable and much appreciated, both for insights it gives to users and to the maintainers as well. So I hope you do go forward with it. Feel free to ping me (head of devrel) if you need any help, feedback, etc.