-
Notifications
You must be signed in to change notification settings - Fork 77
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
[vscode installation] 1/n Python version validation #1262
Conversation
ea09b0d
to
b1ed371
Compare
b1ed371
to
0088eaa
Compare
c798acc
to
efd4e79
Compare
* @returns A promise that resolves to a boolean indicating if the version is >= 3.10. | ||
*/ | ||
|
||
export function isPythonVersionAtLeast310(pythonPath: string): boolean { |
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.
I think this is ok to unblock but ideally if there's some way we can determine the required python version dynamically via pip or something that would be best
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.
what do you mean by dynamically?
also just noting that pip itself has versions, which is not the same as python's version
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.
Oh, what I mean is our pyproject.toml defines requires-python = ">=3.10"
and that shows up as metadata in pip. Ideally we could dynamically get that version in the code without having to hardcode it
export function isPythonVersionAtLeast310(pythonPath: string): boolean { | ||
try { | ||
// Use Python to check compatible version | ||
const command = `${pythonPath} -c "import sys; print(sys.version_info >= (3, 10))"`; |
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.
Why this command vs just doing --version
check? IMO that would be cleaner so that we can do the comparison in code ourselves
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.
Actually, we already should have that version from stdout above, right? I don't think we need to run any python here at all
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.
executing python --version
returns a literal such as Python 3.11.7
.
Felt like parsing this into a version number and then comparing added extra complexity than using python itself to validate version.
I can update if that would be easier to follow
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.
Ah, ok. I guess there are some nuances with it as well (e.g. comparator of version numbers). I'm fine with keeping as-is using python to check
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.
Can we just use the python version from stdout and compare it to a constant (with note to keep constant in sync with our aiconfig package and maybe a TODO to look into getting it dynamically from pip)
Ok, so let's keep the check logic as-is but please address the other comments:
On top of that, please update the comment to give more context on using python to check version (namely complexity of different version values and how they would need to be parsed and compared) |
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.
Accepting to unblock once latest comment is addressed
Add a helper method to validate the python interpreter version. Simply throws an error on a bad version. Notification dialog in diff on top. Align's with Python AIConfig's version requirement of python3.10 and higher ## Testplan Select a python interpreter 3.9, which is less than aiconfig's requirement version of 3.10. https://github.com/lastmile-ai/aiconfig/assets/141073967/4cfcb153-50aa-40fb-9764-54e964d4b1b8
efd4e79
to
57e9a39
Compare
Can revisit the hardcoded dependency of python |
[vscode installation] 1/n Python version validation
Add a helper method to validate the python interpreter version. Simply throws an error on a bad version. Notification dialog in diff on top.
Align's with Python AIConfig's version requirement of python3.10 and higher
Testplan
Select a python interpreter 3.9, which is less than aiconfig's requirement version of 3.10.
output.mp4
Stack created with Sapling. Best reviewed with ReviewStack.