New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error message when no valid Python interpreter can be resolved #7628
Improve error message when no valid Python interpreter can be resolved #7628
Conversation
# NB: self.setup() requires filters to be passed, or else it will use the global interpreter | ||
# constraints. We allow any interpreter other than CPython 3.0-3.3, which is known to choke | ||
# with Pants. | ||
for interpreter in self.setup(filters=("CPython<3", "CPython>=3.3", "PyPy")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewers, am I missing any other Python versions that Pants supports? IronPy or anything maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
While it would be great to have a test for this branch of the code itself (it's fairly large!), I'm fine with merging as is, since this is a huge improvement.
Would you mind following up to add an integration test covering this?
I verified the case that you mentioned in the description, and merged. Thanks! |
Happy to! Although I have no idea how to do so hermetically. The main functionality we should test is grabbing all of the interpreters on the system. I don't know how to do this in a way that works on multiple platforms. One idea, use Any recommendations? |
@Eric-Arellano : I would just do the same thing you did in the description: add an integration test with a(n even more) ridiculous python version, and confirm that you see a relevant snippet from your error message. |
We wouldn't be testing that we are grabbing all interpreters, though. Is this okay? What we would end up testing is
Definitely value in this, just not testing the whole thing. |
Yes, IMO. I'm more concerned with the whole codepath breaking due to an undefined variable or something. |
…preter can be resolved (#7630) While we currently do check that the branch for no valid interpreter being detected works, the check is not very comprehensive. In #7628, we made the logged error message even more complex, so it becomes even more important to check that we are logging the error message correctly.
Problem
Currently, when a valid interpreter cannot be found, such as by running
PANTS_PYTHON_SETUP_INTERPRETER_CONSTRAINTS="['CPython==3.9.*']" ./pants test tests/python/pants_test/util:strutil
, we will print something like this:A user reported that they were very confused by this message. It seems the main issue was not explaining what to do to fix it, which led to them searching through GitHub and getting confused with our Python 3 migration efforts (e.g.
pants_runtime_python_version
) vs. setting constraints for your own code.The other motivating factor is our setup repo failing to find a Python 3.6+ interpreter, despite us knowing for a fact that it is installed and on the PATH. https://travis-ci.org/pantsbuild/setup/jobs/524685486#L355. Here, it would be extremely helpful if we knew what Pants is resolving.
Solution
Improve the message to do two things:
Result
Now running
PANTS_PYTHON_SETUP_INTERPRETER_CONSTRAINTS="['CPython==3.9.*']" ./pants test tests/python/pants_test/util:strutil
results in this more helpful message: