-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Don't proceed into setup.py too far if Python version is unsupported #42870
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
Conversation
💊 CI failures summary and remediationsAs of commit a9e5ff7 (more details on the Dr. CI page): ✅ None of the CI failures appear to be your fault 💚
🚧 1 ongoing upstream failure:These were probably caused by upstream breakages that are not fixed yet:
This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group. This comment has been revised 13 times. |
|
Please let me know if we also want to cap the maximum version here. For example, this confusion #42832 (comment) seems to be caused by Python 3.9, greater than our maximum supported version: #42832 (comment) The downside is that we might have to also allow people to experiment newer version of Python by giving them some "backdoor" to go through. |
b199d25 to
7930853
Compare
7930853 to
05cc473
Compare
|
@pytorchbot merge this please |
setup.py
Outdated
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'm surprised there isn't a more compact way to write this code
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.
me, too (not I'm aware of)
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.
https://pypi.org/project/semver/ may make the code simple, but need to introduce a new dependency...
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.
How about the following?
| python_max_version_str = '.'.join((str(num) for num in python_max_version)) | |
| python_max_version_str = '.'.join(map(str, python_max_version)) |
|
The max version check seems unnecessary and going to force us to keep modifying this bound, even if we are actually compatible with a new version of Python? |
|
Yeah, that's the downside of having a maximum version imposed. I think it really depends on what we would like to achieve. Pros:
Cons:
Of course, we can add a switch, but I think that would be too complicated for this purpose. Please let me know which way the PyTorch team would like to go; I'm fine with either. |
setup.py
Outdated
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.
Hmm, why not use some python3 features like f-strings here?
| import platform | |
| python_min_version = (3, 6, 1) | |
| python_min_version_str = '.'.join((str(num) for num in python_min_version)) | |
| python_max_version = (3, 9, 0) | |
| python_max_version_str = '.'.join((str(num) for num in python_max_version)) | |
| if sys.version_info < python_min_version or sys.version_info >= python_max_version: | |
| print("You are using Python {}. Python >={},<{} is required.".format(platform.python_version(), | |
| python_min_version_str, | |
| python_max_version_str)) | |
| sys.exit(-1) | |
| def tuple2str(t, sep='.'): | |
| return sep.join(map(str, t)) | |
| python_min_version = (3, 6, 1) | |
| python_max_version = (3, 9, 0) | |
| if sys.version_info < python_min_version or sys.version_info >= python_max_version: | |
| print(f"You are using Python {tuple2str(sys.version_info[:3]}. Python >={tuple2str(python_min_version)},<{tuple2str(python_max_version)} is required.") | |
| sys.exit(-1) |
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.
You would receive syntax error if Python is < 3.6, and that's exactly the situation where we are trying to have a reasonable error message.
|
So... would we proceed? |
|
I'm going to pull out my veto power, and say, purely on the perspective of not wanting to have to update hardcoded Python version every time a new Python version comes out, let's get rid of the upper bound. |
This prevents confusing errors when the interpreter encounters some syntax errors in the middle.
05cc473 to
a9e5ff7
Compare
| ], | ||
| 'Programming Language :: C++', | ||
| 'Programming Language :: Python :: 3', | ||
| ] + ['Programming Language :: Python :: 3.{}' for i in range(python_min_version[1], python_max_version[1])], |
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.
@ezyang Do you think this is a reasonable solution? You've got to change the classifier any way.
facebook-github-bot
left a comment
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.
@ezyang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This prevents confusing errors when the interpreter encounters some
syntax errors in the middle.