https://pantsbuild.org/ logo
#general
Title
# general
c

cold-soccer-63228

05/19/2022, 9:04 PM
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

bitter-ability-32190

05/19/2022, 9:06 PM
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

cold-soccer-63228

05/19/2022, 9:06 PM
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

bitter-ability-32190

05/19/2022, 9:07 PM
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

cold-soccer-63228

05/19/2022, 9:12 PM
Awesome, I think that fixes it. Thanks Josh!
🙌 1
h

happy-kitchen-89482

05/19/2022, 10:30 PM
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

wide-midnight-78598

05/19/2022, 10:45 PM
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....
4 Views