-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
MAINT: replace optparse with argparse for 'doc' and 'tools' scripts #15702
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
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.
Creafully went through all of this, and did not find any issue/potential error. I would be happy to put this in, if this breaks something, it will break very loudly and be easy to fix.
d7905eb
to
521fd30
Compare
As for |
Since some of this touches distutils, I would like @rgommers to give his OK. |
Please do not touch distutils. The optparse note says "it will not be developed further" and not "it will be removed in the future", so I am comfortable leaving it as-is. |
@mattip why not distutils? It's still maintained. I'm only aware that npy_tempita is not to receive any maintanance. I don't understand the argument why use of deprecated modules should be left as-is, even if it's unlikely to be removed. There are clear benefits of using supported upstream modules. |
The module is very fragile, and due to its nature is difficult to test: it is used by many more architectures, compilers, operating systems, shells, and python variants than we can test for. Breaking it is very expensive in terms of developer time to find the fix. Even replicating the failure can be such a daunting task that we simply end up reverting the change. Then we have to try to work out which change to revert, which is also non-trivial since some users only update once every few years. We are even more unlikely to start using advanced features of argparse for the same reason. We could find out 3 years down the road that we broke someone's workflow by slightly changing some nuance in parsing command line arguments. It could take weeks to chase down the broken build with little indication that the problem is that the compiler invocation ended up having an extra space in the command, and this particular shell used to compile doesn't handle spaces. So in the balance, we would prefer not to change distutils unless motivated by a user-reported issue. |
Let's break this into two PRs, one for the distutils files and one for the rest. I'm not as concerned as Ralf is about fooling with distutils, I think we did alright with the subprocess change and that change had more subtle effects than this. However, I don't want to hang this PR up over the dispute. |
@mattip thanks for the explanation! Yes, agree about the fragility of the module, and the consequences of any misstep. However it is also a good argument to move away from deprecated modules to supported modules... |
Thanks @mwtoews . |
The optparse module is deprecated since Python 2.7/3.2. This PR upgrades a few scripts to use argparse.
Because these tools are not really part of the CI testing, they need some manual checks. Here is a summary for each tool:
doc/postprocess.py
still in used, and checked withGITVER=91118b3363 make html
doc/summarize.py
not used, does not work (ModuleNotFoundErrror), and probably not used since numpy 1.7 (when e.g.doc/sphinxext/phantom_import.py
existed); follow-up with Tool doc/summarize.py does not work #15708numpy/distutils/npy_pkg_config.py
not sure how to test from command line; follow-up with MAINT: replace optparse with argparse for 'distutils' scripts #15728numpy/distutils/system_info.py
appears to still be in-use, and works as beforetools/c_coverage/c_coverage_report.py
still in usetools/npy_tempita/__init__.py
not considered in this PR, as this module is left-alone