I upgraded my project Python <3.10.7 to> 3.10.8 an...
# general
c
I upgraded my project Python 3.10.7 to 3.10.8 and now I’m getting this:
Copy code
./pants fmt :: 
Bootstrapping Pants using /opt/homebrew/bin/python3.8
Installing pantsbuild.pants==2.14.0 into a virtual environment at /Users/dfarrell/.cache/pants/setup/bootstrap-Darwin-arm64/2.14.0_py38
ERROR: Could not find a version that satisfies the requirement pantsbuild.pants==2.14.0 (from versions: 0.0.17, 0.0.18, 0.0.20, 0.0.21, 0.0.22, 0.0.23, 0.0.24, 0.0.25, 0.0.26, 0.0.27, 0.0.28, 0.0.29, 0.0.30, 0.0.31, 0.0.32, 0.0.33, 0.0.34, 0.0.35, 0.0.36, 0.0.37, 0.0.38, 0.0.39, 0.0.40, 0.0.41, 0.0.42, 0.0.43, 0.0.44, 0.0.45, 0.0.46, 0.0.47, 0.0.48, 0.0.49, 0.0.50, 0.0.51, 0.0.52, 0.0.53, 0.0.54, 0.0.55, 0.0.56, 0.0.57, 0.0.58, 0.0.59, 0.0.60, 0.0.61, 0.0.62, 0.0.63, 0.0.64, 0.0.65, 0.0.66, 0.0.67, 0.0.68, 0.0.69, 0.0.70, 0.0.71, 0.0.72, 0.0.73, 0.0.74, 0.0.75, 0.0.76, 0.0.77, 0.0.79, 0.0.80, 0.0.81, 0.0.82, 1.0.0, 1.0.1, 1.1.0, 1.2.0, 1.2.1, 1.3.0, 1.4.0, 1.5.0, 1.6.0, 1.7.0)
ERROR: No matching distribution found for pantsbuild.pants==2.14.0
Is 3.10.8 not supported, or am I missing something?
Somehow I’ve managed to break pants. Even if I run just
./pants --version
I get the above output
w
Are you on an m1
? If so, you'll need to use Python 3.9 as a runner: https://www.pantsbuild.org/docs/prerequisites#macos
h
Pants itself requires 3.7-3.9 to run itself (must be 3.9 on an m1), and you’re using
/opt/homebrew/bin/python3.8
, which should be fine. This is unrelated to the interpreter you use for your own code, which can be anything
So the
3.10.8
thing may be a red herring, or an inadvertent cause of trouble
Did you perturb the interpreters on your system in some way?
w
Copy code
/Users/dfarrell/.cache/pants/setup/bootstrap-Darwin-arm64/2.14.0_py38
Darwin arm64?
h
Ah yes!
Must be 3.9 on m1s
w
Doesn't the
pants
script error out if it can't find a supported Python runner?
c
I am on an M1 MacBook
Does that mean I need my project to use 3.9, or just pants?
h
Just Pants
your project can use anything
1
We really should have the script error out on m1s if it can’t find 3.9
But basically you need to make sure a 3.9 is available on your path
PS coming soon, hopefully - Pants packaged up with its own interpreter, so you don’t have to worry about any of this
c
I have Python 3.9.7 installed via pyenv, and I just tried re-installing
pants
, and got the same error (I moved my pants.toml file to a saved location). Is there something else I need to do to let pants find the Python 3.9.7 version?
w
I use a
pants.rc
file - otherwise my XCode python gets picked up weirdly. Now it's brew.
Copy code
⏺ ~ % cat ~/.pants.rc
[python-bootstrap]
search_path = ["/usr/local/bin"]
PyEnv should be picked up pretty readily, so I'm surprised
c
It also looks like it’s bootstrapping from the Homebrew Python 3.8. Is there some way to get it to use the pyenv Python 3.9.7 version instead?
D’OH! You beat me to my question @wide-midnight-78598 🙂
👍 1
Hmmm made the change to my
pants.toml
file, no effect…
Copy code
[python-bootstrap]
search_path = [
    # This will use all the interpretrs in `$(pyenv root)/versins`.
    "<PYENV>"
]
h
This must be frustrating! Sorry.
Try nuking
~/.cache/pants/setup
and starting over?
c
That’s okay, it’s new to me, and I think pants is worth putting on. See what I did there… 🙂
👖 1
w
Also, I would put that
bootstrap
in a
.pants.rc
in your home dir, that way being in a different directory won't cause this all to happen again
c
Ahhh, good plant
h
That search_path setting is for interpreter discovery for your own code
The
pants
script is what selects the interpreter for Pants itself to run on
so you might have to tweak it manually to force it to do your bidding…
c
I’ll take a look at that as after following the above suggestions it’s still using the homebrew Python 3.8
Sigh, I can’t uninstall Brew Python 3.8 as it’s used by aws-sam-cli… 😞
Should I edit the ~/.cache/pants/setup/bootstrap/pants.fk997B/install/pyvenv.cfg file?
w
search_path setting is for interpreter discovery for your own code
Doh! That's right, the weird system python issue I was having was directly AFTER pants was installed. Blah...
For picking a python Pants runner, isn't there an env var that can be set?
Like...
PYTHON=/usr/local/bin/... ./pants --version
?
c
Is this what you mean from the pants script itself:
Copy code
# Source any custom bootstrap settings for Pants from PANTS_BOOTSTRAP if it exists.
: ${PANTS_BOOTSTRAP:=".pants.bootstrap"}
if [[ -f "${PANTS_BOOTSTRAP}" ]]; then
  source "${PANTS_BOOTSTRAP}"
fi
?
I think I figured it out. I had a
.python-version
file in the project directory that was referencing
3.10.8
(my project Python version) that was created by pyenv when I built the local
.venv
file. This was screwing up pants
h
Ugh. Hopefully soon we’ll be able to distribute pants as a standalone executable that contains its own interpreter, and get rid of all these issues once and for all.
c
Pants is amazing already. This problem doesn’t diminish that at all, at least to my way of thinking. 🙂
❤️ 1
🙏 1