-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Refactor call_subprocess()
to not raise InstallationError
#7711
Comments
Looking at the usage of
The sections which are calling this that aren't "install" stuff, are in "build" and "vcs" -- both of which are potentially reachable in a I feel like the best approach here is to add a If we want to tackle this incrementally, we could start by adding a |
If we always catch |
i can try taking a stab at this |
call_subprocess()
to no raise InstallationError
call_subprocess()
to not raise InstallationError
@swchoi727 Go ahead! |
What's the problem this feature will solve?
As mentioned in #7593 (comment),
call_subprocess()
currently raisesInstallationError
, but that function is used in a lot of places, many of them are not really related to installing things.Its design is also limiting if the caller wants to get information other than merged stdout/stderr output.
Describe the solution you'd like
Introduce a wrapper
call_subprocess_for_install()
for existing usages that work the same as the currentcall_subprocess
, and change most of the currentcall_subprocess
invocations to use that instead. No changes are made except the name, since there are far too many invocations relying on the implicitInstallationError
for flow control.call_subprocess_for_install()
would delegate most of its work to a refactoredcall_subprocess()
, which would return a composite object, similar tosubprocess.CompletedProcess
introduced in Python 3.5, to hold information of the subprocess result. Callers expecting the subprocess to not return 0 can call this function instead, and check the return code and stderr without needing to catchInstallationError
.Alternative Solutions
InstallationError
. Not ideal, but I am actually OK with that TBH.call_subprocess
calls in tack, but raise something else instead. This would affect all usages that rely on the implicitInstallationError
. This feels risky for me since there are a lot of indirect usages, and it would be a pain to hunt down all of them and wrap the call in araise InstallationError
.call_subprocess
is only for installing things, and invent something else under other contexts. This is also a good solution IMO, and since mostcall_subprocess
usages are in the installation context, it’s not nearly as difficult to hunt them down an invokesubprocess.Popen
instead. But it would still be a good idea IMO to change the name ofcall_subprocess
, and if that’s the case, why not make its internal useful for other situations.The text was updated successfully, but these errors were encountered: