-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
Add pants_runtime_python_version global option #7363
Add pants_runtime_python_version global option #7363
Conversation
Reviewers: I added so many of you all because I wanted your feedback on the option name Also this option is not going to go away once we drop Py2, as users will still be able to choose between 3.6 vs. 3.7. The important thing to make sure we're communicating with this option name is that this does not impact the interpreter they use for their own code, e.g. in their tests and other spawned subprocesses. This solely determines what Pants itself uses to run. -- Please refer to pantsbuild/setup#30 for the plan on how this will all hook up. |
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.
Thanks!
Danny and Stu have a point that it's better to expose this info directly to the user, rather than keeping it in a comment in source code. I originally was thinking we'd want to keep the help message shorter, and rely on the message in the runtime check to steer people the right way, but this is bad reasoning. I can't think of a time I was upset a help message was too long (so long as it was concise and everything had a reason to be there)..
We first need to land pantsbuild/pants#7363 and then release Pants with it or else the option will error out.
Yay time to bikeshed! My first preference would be I also have a vague question around where we should be using exact versions and where we should be using constraints... |
To recap, we now have multiple proposals for what to call the global option users will put in their
My main priority is distinguishing between options like Edit: added Benjy and Borja's proposals. |
Does the word "runtime" help with this emphasis? E.g., |
I do like the verboseness of that option and I wouldn't be afraid of being overly verbose, since this is a thing that is written down in a config file, not typed in a terminal. I'm not sure I like the word How about something like Love a good bikeshedding session. |
My two cents:
|
+1 for Mathieu's suggestion. |
Thank you all. We've narrowed it down to:
Thoughts on which of the two? My two cents, I'd be happy with either. I prefer |
I prefer |
I have a pretty strong preference away from |
I don't have strong feelings either way. But if So I would vote: |
I like |
It looks like |
…improve comments Make explicit reference to the setup repo and our ./pants script we distribute. The average user will end up wanting to use this script, so it's good to remind them that we will parse these versions and resolve them automatically.
raise BuildConfigurationError( | ||
'Running Pants with a different Python interpreter version than requested. ' | ||
'You requested {}, but are running with {}.\n\n' | ||
'Note that Pants cannot use the value you give for `--pants-engine-python-version` to ' |
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.
This is using the previous option name.
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.
Oof. I thought I had fixed all the instances of this. Will hotfix this as part of #7365. Thanks for the catch!
Problem
As discussed in pantsbuild/setup#30, we decided to add support for using Python 3 to every day user's setup script
./pants
by having them pin the interpreter version they want to use inpants.ini
, and then grepping that value to choose the relevant interpreter. However, this currently results in this error:Solution
Exactly how we handle
--pants-version
, introduce a new global option--pants-runtime-python-version
that allows users to setpants_runtime_python_version
in theirpants.ini
.Even though Pants code cannot dynamically change the interpreter it runs with—as it is too late to change the interpreter once the process is already running—we can check that Pants is running with the intended interpreter and print a helpful message if it is not.
You can leave off the option, and you'll get no runtime check. Setup scripts are free to implement Python interpreter resolution in another way if they prefer.
Result
pants_runtime_python_version
inpants.ini
no longer results in an error../pants --pants-runtime-python-version=2.6
will error out. Running./pants2 --pants-runtime-python-version=2.7
will work normally.