Hello, a coworker of mine is running into some tro...
# general
c
Hello, a coworker of mine is running into some trouble when using Pants. In our
pants.toml
file, we have the following:
Copy code
[python]
interpreter_constraints = ["CPython==3.9.*"]
However, when he runs Pants commands, he sees the following line:
Copy code
Bootstrapping Pants using /usr/local/bin/python3.7
This is problematic because we use Python 3.9 features, which is causing his runtime to fail. What is the reason that Python 3.7 is being used here?
1
b
Pants uses Python to run itself. Your first config is the ICs Pants should use to run your code. It should be OK (in most cases) that Pants runs itself with 3.7, but your code with 3.9. What's the error? In a plugin?
(plugins and macros are those places where what version Pants runs itself with matters)
c
Yup, in a plugin! I do the following in there
Copy code
from typing import Final
And
typing.Final
isn't valid until Python 3.8 😕
b
Ah yeah, might want to do
from __future__ import annotations
and then also
if TYPECHECKING: from typing import Final
Eventually Pants won't use the user's Python to run itself... https://github.com/pantsbuild/pants/issues/7369 ...eventually 😛
c
Awesome, I think that fixes it. Thanks Josh!
🙌 1
h
Ah, right, Pants can run on 3.7 but run your code on 3.9, no problem (think of that 3.7 as an implementation detail of Pants). The only time this isn't quite true is in-repo Pants plugins.
Because those are running in-process in Pants
But you can always modify your
./pants
script to modify the interpreters it's willing to bootstrap with
w
https://www.pantsbuild.org/docs/options#pantsrc-file
pants.rc
is definitely your friend on this one. My Xcode python get's periodically pulled in for some reason. At least it used to....